)
{
@@ -365,7 +365,7 @@ sub read_relative_infiles
next if /^$/;
# The infile must begin with the system variable values.
- # Therefore, the first occurance of Aborted_clients indicates the beginning
+ # Therefore, the first occurrence of Aborted_clients indicates the beginning
# of the first set of status values if no sets have occurred yet ($stat_n == 0).
# In this case, the following status values are printed to the current fh,
# along with the system variable values read thus far, until Aborted_clients
diff --git a/debian/mariadb-server-10.1.mysql.init b/debian/mariadb-server-10.1.mysql.init
index 91d07e8de3e8d..c15983c13d015 100644
--- a/debian/mariadb-server-10.1.mysql.init
+++ b/debian/mariadb-server-10.1.mysql.init
@@ -25,7 +25,7 @@ SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
CONF=/etc/mysql/my.cnf
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
-# priority can be overriden and "-s" adds output to stderr
+# priority can be overridden and "-s" adds output to stderr
ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mysql -i"
# Safeguard (relative paths, core dumps..)
diff --git a/debian/mariadb-server-10.1.postinst b/debian/mariadb-server-10.1.postinst
index ccf7d5c88ca29..eede069ae12de 100644
--- a/debian/mariadb-server-10.1.postinst
+++ b/debian/mariadb-server-10.1.postinst
@@ -239,7 +239,7 @@ db_stop # in case invoke failes
# dh_systemd_start doesn't emit anything since we still ship /etc/init.d/mysql.
# Thus MariaDB server is started via init.d script, which in turn redirects to
# systemctl. If we upgrade from MySQL mysql.service may be masked, which also
-# means init.d script is disabled. Unmask mysql service explicitely.
+# means init.d script is disabled. Unmask mysql service explicitly.
# Check first that the command exists, to avoid emitting any warning messages.
if [ -x "$(command -v deb-systemd-helper)" ]; then
deb-systemd-helper unmask mysql.service > /dev/null
diff --git a/extra/charset2html.c b/extra/charset2html.c
index cafac2c1cd5f3..5851f206a1c5b 100644
--- a/extra/charset2html.c
+++ b/extra/charset2html.c
@@ -97,7 +97,7 @@ static void print_cs(CHARSET_INFO *cs)
{
/*
Control characters 0x0080..0x009F are dysplayed by some
- browers as if they were letters. Don't print them to
+ browsers as if they were letters. Don't print them to
avoid confusion.
*/
printf("ctrl | ctrl | ctrl");
diff --git a/extra/replace.c b/extra/replace.c
index 56cf02f200236..a9982670384a2 100644
--- a/extra/replace.c
+++ b/extra/replace.c
@@ -36,7 +36,7 @@
The programs make a DFA-state-machine of the strings and the speed isn't
dependent on the count of replace-strings (only of the number of replaces).
A line is assumed ending with \n or \0.
- There are no limit exept memory on length of strings.
+ There are no limit except memory on length of strings.
Written by Monty.
fill_buffer_retaining() is taken from gnu-grep and modified.
diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt
index 417f91c787985..8e60d2675214f 100644
--- a/libmysql/CMakeLists.txt
+++ b/libmysql/CMakeLists.txt
@@ -476,7 +476,7 @@ IF(NOT DISABLE_SHARED)
EXPORTS ${CLIENT_API_FUNCTIONS} ${CLIENT_API_5_1_EXTRA} ${CLIENT_API_5_5_EXTRA}
COMPONENT SharedLibraries)
IF(UNIX)
- # libtool compatability
+ # libtool compatibility
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR APPLE)
SET(OS_SHARED_LIB_VERSION "${SHARED_LIB_MAJOR_VERSION}")
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 4d7d8a380a757..477314b0af3c5 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -195,7 +195,7 @@ int STDCALL mysql_server_init(int argc __attribute__((unused)),
the library.
To make things simpler when used with windows dll's (which calls this
- function automaticly), it's safe to call this function multiple times.
+ function automatically), it's safe to call this function multiple times.
*/
@@ -220,7 +220,7 @@ void STDCALL mysql_server_end()
}
#ifdef NOT_NEEDED
/*
- The following is not needed as if the program explicitely called
+ The following is not needed as if the program explicitly called
my_init() then we can assume it will also call my_end().
The reason to not also do it here is in that case we can't get
statistics from my_end() to debug log.
@@ -605,7 +605,7 @@ static int default_local_infile_init(void **ptr, const char *filename,
default_local_infile_read()
ptr Points to handle allocated by _init
buf Read data here
- buf_len Ammount of data to read
+ buf_len Amount of data to read
RETURN
> 0 number of bytes read
@@ -660,7 +660,7 @@ static void default_local_infile_end(void *ptr)
ptr Points to handle allocated by _init
May be NULL if _init failed!
error_msg Store error text here
- error_msg_len Max lenght of error_msg
+ error_msg_len Max length of error_msg
RETURN
error message number
@@ -1270,7 +1270,7 @@ static int stmt_read_row_no_result_set(MYSQL_STMT *stmt, unsigned char **row);
static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data);
static my_bool setup_one_fetch_function(MYSQL_BIND *, MYSQL_FIELD *field);
-/* Auxilary function used to reset statement handle. */
+/* Auxiliary function used to reset statement handle. */
#define RESET_SERVER_SIDE 1
#define RESET_LONG_DATA 2
@@ -1814,7 +1814,7 @@ static void update_stmt_fields(MYSQL_STMT *stmt)
RETURN
NULL statement contains no result set or out of memory.
- In the latter case you can retreive error message
+ In the latter case you can retrieve error message
with mysql_stmt_error.
MYSQL_RES a result set with no rows
*/
@@ -1852,7 +1852,7 @@ mysql_stmt_result_metadata(MYSQL_STMT *stmt)
Returns parameter columns meta information in the form of
result set.
- SYNOPSYS
+ SYNOPSIS
mysql_stmt_param_metadata()
stmt statement handle
@@ -1901,7 +1901,7 @@ static void store_param_type(unsigned char **pos, MYSQL_BIND *param)
param MySQL bind param
DESCRIPTION
- These funtions are invoked from mysql_stmt_execute() by
+ These functions are invoked from mysql_stmt_execute() by
MYSQL_BIND::store_param_func pointer. This pointer is set once per
many executions in mysql_stmt_bind_param(). The caller must ensure
that network buffer have enough capacity to store parameter
@@ -2078,7 +2078,7 @@ static my_bool store_param(MYSQL_STMT *stmt, MYSQL_BIND *param)
/*
- Auxilary function to send COM_STMT_EXECUTE packet to server and read reply.
+ Auxiliary function to send COM_STMT_EXECUTE packet to server and read reply.
Used from cli_stmt_execute, which is in turn used by mysql_stmt_execute.
*/
@@ -4466,7 +4466,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt)
if (stmt->update_max_length && !stmt->bind_result_done)
{
/*
- We must initalize the bind structure to be able to calculate
+ We must initialize the bind structure to be able to calculate
max_length
*/
MYSQL_BIND *my_bind, *end;
diff --git a/mysys/array.c b/mysys/array.c
index 35a41f2222ce7..5548ca1b69482 100644
--- a/mysys/array.c
+++ b/mysys/array.c
@@ -90,7 +90,7 @@ my_bool insert_dynamic(DYNAMIC_ARRAY *array, const void * element)
{
void *buffer;
if (array->elements == array->max_element)
- { /* Call only when nessesary */
+ { /* Call only when necessary */
if (!(buffer=alloc_dynamic(array)))
return TRUE;
}
diff --git a/mysys/hash.c b/mysys/hash.c
index d59e63bddc4b3..3c17dcb991c42 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -61,7 +61,7 @@ my_hash_value_type my_hash_sort(CHARSET_INFO *cs, const uchar *key,
@param[in,out] hash The hash that is initialized
@param[in[ growth_size size incrememnt for the underlying dynarray
- @param[in] charset The charater set information
+ @param[in] charset The character set information
@param[in] size The hash size
@param[in] key_offest The key offset for the hash
@param[in] key_length The length of the key used in
@@ -618,7 +618,7 @@ my_bool my_hash_delete(HASH *hash, uchar *record)
/**
Update keys when record has changed.
- This is much more efficent than using a delete & insert.
+ This is much more efficient than using a delete & insert.
*/
my_bool my_hash_update(HASH *hash, uchar *record, uchar *old_key,
diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c
index b349ef88ed13f..11fde0ef844b8 100644
--- a/mysys/lf_alloc-pin.c
+++ b/mysys/lf_alloc-pin.c
@@ -139,7 +139,7 @@ void lf_pinbox_destroy(LF_PINBOX *pinbox)
Get pins from a pinbox. Usually called via lf_alloc_get_pins() or
lf_hash_get_pins().
- SYNOPSYS
+ SYNOPSIS
pinbox -
DESCRIPTION
@@ -443,7 +443,7 @@ static void alloc_free(uchar *first,
/*
initialize lock-free allocator
- SYNOPSYS
+ SYNOPSIS
allocator -
size a size of an object to allocate
free_ptr_offset an offset inside the object to a sizeof(void *)
diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c
index 6be11edbfcfa5..dfddc1ce442ce 100644
--- a/mysys/lf_hash.c
+++ b/mysys/lf_hash.c
@@ -201,7 +201,7 @@ static LF_SLIST *l_insert(LF_SLIST * volatile *head, CHARSET_INFO *cs,
lf_unpin(pins, 2);
/*
Note that cursor.curr is not pinned here and the pointer is unreliable,
- the object may dissapear anytime. But if it points to a dummy node, the
+ the object may disappear anytime. But if it points to a dummy node, the
pointer is safe, because dummy nodes are never freed - initialize_bucket()
uses this fact.
*/
@@ -333,7 +333,7 @@ static void default_initializer(LF_HASH *hash, void *dst, const void *src)
lf_alloc and a size of memcpy'ed block size in lf_hash_insert. Typically
they are the same, indeed. But LF_HASH::element_size can be decreased
after lf_hash_init, and then lf_alloc will allocate larger block that
- lf_hash_insert will copy over. It is desireable if part of the element
+ lf_hash_insert will copy over. It is desirable if part of the element
is expensive to initialize - for example if there is a mutex or
DYNAMIC_ARRAY. In this case they should be initialize in the
LF_ALLOCATOR::constructor, and lf_hash_insert should not overwrite them.
@@ -442,7 +442,7 @@ int lf_hash_delete(LF_HASH *hash, LF_PINS *pins, const void *key, uint keylen)
hashnr= hash->hash_function(hash->charset, (uchar *)key, keylen) & INT_MAX32;
- /* hide OOM errors - if we cannot initalize a bucket, try the previous one */
+ /* hide OOM errors - if we cannot initialize a bucket, try the previous one */
for (bucket= hashnr % hash->size; ;bucket= my_clear_highest_bit(bucket))
{
el= lf_dynarray_lvalue(&hash->array, bucket);
@@ -476,7 +476,7 @@ void *lf_hash_search_using_hash_value(LF_HASH *hash, LF_PINS *pins,
LF_SLIST * volatile *el, *found;
uint bucket;
- /* hide OOM errors - if we cannot initalize a bucket, try the previous one */
+ /* hide OOM errors - if we cannot initialize a bucket, try the previous one */
for (bucket= hashnr % hash->size; ;bucket= my_clear_highest_bit(bucket))
{
el= lf_dynarray_lvalue(&hash->array, bucket);
diff --git a/mysys/ma_dyncol.c b/mysys/ma_dyncol.c
index 92418e38c2e70..1909c0fd9a38c 100644
--- a/mysys/ma_dyncol.c
+++ b/mysys/ma_dyncol.c
@@ -2066,7 +2066,7 @@ static uchar *find_entry_named(DYN_HEADER *hdr, LEX_STRING *key)
/**
Write number in the buffer (backward direction - starts from the buffer end)
- @return pointer on the number begining
+ @return pointer on the number beginning
*/
static char *backwritenum(char *chr, uint numkey)
@@ -2136,7 +2136,7 @@ find_column(DYN_HEADER *hdr, uint numkey, LEX_STRING *strkey)
hdr->length= hdr_interval_length(hdr, hdr->entry + hdr->entry_size);
hdr->data= hdr->dtpool + hdr->offset;
/*
- Check that the found data is withing the ranges. This can happen if
+ Check that the found data is within the ranges. This can happen if
we get data with wrong offsets.
*/
if (hdr->length == DYNCOL_OFFSET_ERROR ||
@@ -3480,7 +3480,7 @@ dynamic_column_update_many_fmt(DYNAMIC_COLUMN *str,
if (plan[i].val->type == DYN_COL_NULL)
{
- plan[i].act= PLAN_NOP; /* Mark entry to be skiped */
+ plan[i].act= PLAN_NOP; /* Mark entry to be skipped */
}
else
{
@@ -4129,7 +4129,7 @@ mariadb_dyncol_json_internal(DYNAMIC_COLUMN *str, DYNAMIC_STRING *json,
hdr_interval_length(&header, header.entry + header.entry_size);
header.data= header.dtpool + header.offset;
/*
- Check that the found data is withing the ranges. This can happen if
+ Check that the found data is within the ranges. This can happen if
we get data with wrong offsets.
*/
if (header.length == DYNCOL_OFFSET_ERROR ||
@@ -4269,7 +4269,7 @@ mariadb_dyncol_unpack(DYNAMIC_COLUMN *str,
hdr_interval_length(&header, header.entry + header.entry_size);
header.data= header.dtpool + header.offset;
/*
- Check that the found data is withing the ranges. This can happen if
+ Check that the found data is within the ranges. This can happen if
we get data with wrong offsets.
*/
if (header.length == DYNCOL_OFFSET_ERROR ||
diff --git a/mysys/mf_fn_ext.c b/mysys/mf_fn_ext.c
index b78d73074da3d..debed8afed39f 100644
--- a/mysys/mf_fn_ext.c
+++ b/mysys/mf_fn_ext.c
@@ -86,7 +86,7 @@ char *fn_ext2(const char *name)
if (!(gpos= strrchr(name, FN_LIBCHAR)))
gpos= name;
#endif
- // locate the last occurence of FN_EXTCHAR
+ // locate the last occurrence of FN_EXTCHAR
pos= strrchr(gpos, FN_EXTCHAR);
DBUG_RETURN((char*) (pos ? pos : strend(gpos)));
} /* fn_ext2 */
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c
index 510278c8a4d74..d861c2c3d4f4e 100644
--- a/mysys/mf_iocache.c
+++ b/mysys/mf_iocache.c
@@ -82,7 +82,7 @@ int (*_my_b_encr_write)(IO_CACHE *info,const uchar *Buffer,size_t Count)= 0;
info IO_CACHE handler
NOTES
- This is called on automaticly on init or reinit of IO_CACHE
+ This is called on automatically on init or reinit of IO_CACHE
It must be called externally if one moves or copies an IO_CACHE
object.
*/
@@ -166,7 +166,7 @@ init_functions(IO_CACHE* info)
If == 0 then use my_default_record_cache_size
type Type of cache
seek_offset Where cache should start reading/writing
- use_async_io Set to 1 of we should use async_io (if avaiable)
+ use_async_io Set to 1 of we should use async_io (if available)
cache_myflags Bitmap of different flags
MY_WME | MY_FAE | MY_NABP | MY_FNABP |
MY_DONT_CHECK_FILESIZE
@@ -343,7 +343,7 @@ static void my_aiowait(my_aio_result *result)
if (errno == EINTR)
continue;
DBUG_PRINT("error",("No aio request, error: %d",errno));
- result->pending=0; /* Assume everythings is ok */
+ result->pending=0; /* Assume everything is ok */
break;
}
((my_aio_result*) tmp)->pending=0;
@@ -1999,7 +1999,7 @@ int main(int argc, char** argv)
/* check correctness of tests */
if (total_bytes != status.st_size)
{
- fprintf(stderr,"Not the same number of bytes acutally in file as bytes \
+ fprintf(stderr,"Not the same number of bytes actually in file as bytes \
supposedly written\n");
error=1;
}
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 3263459bd721e..9356f9154f069 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -58,11 +58,11 @@
When a new block is required it is first tried to pop one from the stack.
If the stack is empty, it is tried to get a never-used block from the pool.
If this is empty too, then a block is taken from the LRU ring, flushing it
- to disk, if neccessary. This is handled in find_key_block().
+ to disk, if necessary. This is handled in find_key_block().
With the new free list, the blocks can have three temperatures:
hot, warm and cold (which is free). This is remembered in the block header
by the enum BLOCK_TEMPERATURE temperature variable. Remembering the
- temperature is neccessary to correctly count the number of warm blocks,
+ temperature is necessary to correctly count the number of warm blocks,
which is required to decide when blocks are allowed to become hot. Whenever
a block is inserted to another (sub-)chain, we take the old and new
temperature into account to decide if we got one more or less warm block.
@@ -450,7 +450,7 @@ static inline uint next_power(uint value)
structure of the type SIMPLE_KEY_CACHE_CB that is used for this key cache.
The parameter keycache is supposed to point to this structure.
The parameter key_cache_block_size specifies the size of the blocks in
- the key cache to be built. The parameters division_limit and age_threshhold
+ the key cache to be built. The parameters division_limit and age_threshold
determine the initial values of those characteristics of the key cache
that are used for midpoint insertion strategy. The parameter use_mem
specifies the total amount of memory to be allocated for key cache blocks
diff --git a/mysys/my_access.c b/mysys/my_access.c
index 91a536d214e12..7577424040607 100644
--- a/mysys/my_access.c
+++ b/mysys/my_access.c
@@ -223,7 +223,7 @@ my_bool is_filename_allowed(const char *name __attribute__((unused)),
/*
- Check if a path will access a reserverd file name that may cause problems
+ Check if a path will access a reserved file name that may cause problems
SYNOPSIS
check_if_legal_filename
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index 664a7380ca4c3..7275f602525ce 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -43,7 +43,7 @@
DESCRIPTION
This function prepares memory root for further use, sets initial size of
chunk for memory allocation and pre-allocates first block if specified.
- Altough error can happen during execution of this function if
+ Although error can happen during execution of this function if
pre_alloc_size is non-0 it won't be reported. Instead it will be
reported as error in first alloc_root() on this memory root.
diff --git a/mysys/my_compare.c b/mysys/my_compare.c
index 6de7ff774c0c2..7fb2ef979162c 100644
--- a/mysys/my_compare.c
+++ b/mysys/my_compare.c
@@ -99,12 +99,12 @@ static int compare_bin(const uchar *a, uint a_length,
Example1: if the function is called for tuples
('aaa','bbb') and ('eee','fff'), then
diff_pos[0] = 1 (as 'aaa' != 'eee')
- diff_pos[1] = 0 (offset from beggining of tuple b to 'eee' keypart).
+ diff_pos[1] = 0 (offset from beginning of tuple b to 'eee' keypart).
Example2: if the index function is called for tuples
('aaa','bbb') and ('aaa','fff'),
diff_pos[0] = 2 (as 'aaa' != 'eee')
- diff_pos[1] = 3 (offset from beggining of tuple b to 'fff' keypart,
+ diff_pos[1] = 3 (offset from beginning of tuple b to 'fff' keypart,
here we assume that first key part is CHAR(3) NOT NULL)
NOTES
diff --git a/mysys/my_compress.c b/mysys/my_compress.c
index 78d09bb5f361c..0e4db5c3b1744 100644
--- a/mysys/my_compress.c
+++ b/mysys/my_compress.c
@@ -162,7 +162,7 @@ uchar *my_compress_alloc(const uchar *packet, size_t *len, size_t *complen)
SYNOPSIS
my_uncompress()
- packet Compressed data. This is is replaced with the orignal data.
+ packet Compressed data. This is is replaced with the original data.
len Length of compressed data
complen Length of the packet buffer (must be enough for the original
data)
diff --git a/mysys/my_default.c b/mysys/my_default.c
index 684373a942b85..655e9a5774752 100644
--- a/mysys/my_default.c
+++ b/mysys/my_default.c
@@ -24,7 +24,7 @@
pre- and end 'blank space' are removed from options and values. The
following escape sequences are recognized in values: \b \t \n \r \\
- The following arguments are handled automaticly; If used, they must be
+ The following arguments are handled automatically; If used, they must be
first argument on the command line!
--no-defaults ; no options are read.
--defaults-file=full-path-to-default-file ; Only this file will be read.
@@ -62,7 +62,7 @@
check the pointer, use "----args-separator----" here to ease debug
if someone misused it.
- The args seprator will only be added when
+ The args separator will only be added when
my_getopt_use_args_seprator is set to TRUE before calling
load_defaults();
@@ -597,7 +597,7 @@ int my_load_defaults(const char *conf_file, const char **groups,
(*argv)+= args_used;
/*
- Check if we wan't to see the new argument list
+ Check if we want to see the new argument list
This options must always be the last of the default options
*/
if (*argc >= 2 && !strcmp(argv[0][1],"--print-defaults"))
diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c
index fbdcef88bda90..bfa28f1d37211 100644
--- a/mysys/my_getwd.c
+++ b/mysys/my_getwd.c
@@ -37,7 +37,7 @@
MyFlags Flags
NOTES
- Directory is allways ended with FN_LIBCHAR
+ Directory is always ended with FN_LIBCHAR
RESULT
0 ok
diff --git a/mysys/my_init.c b/mysys/my_init.c
index 32289dbed7ae7..6ec9552c528bb 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -99,7 +99,7 @@ my_bool my_init(void)
if (my_progname)
my_progname_short= my_progname + dirname_length(my_progname);
- /* Initalize our mutex handling */
+ /* Initialize our mutex handling */
my_mutex_init();
if (my_thread_global_init())
@@ -415,7 +415,7 @@ static my_bool win32_init_tcp_ip()
WORD wVersionRequested = MAKEWORD( 2, 2 );
WSADATA wsaData;
/* Be a good citizen: maybe another lib has already initialised
- sockets, so dont clobber them unless necessary */
+ sockets, so don't clobber them unless necessary */
if (WSAStartup( wVersionRequested, &wsaData ))
{
/* Load failed, maybe because of previously loaded
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index a8f7c02ab6324..abc7b8a316146 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -14,7 +14,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-/* TODO: check for overun of memory for names. */
+/* TODO: check for overrun of memory for names. */
#include "mysys_priv.h"
#include
diff --git a/mysys/my_pread.c b/mysys/my_pread.c
index 745cde9ec4136..d3524279ea917 100644
--- a/mysys/my_pread.c
+++ b/mysys/my_pread.c
@@ -28,7 +28,7 @@
SYNOPSIOS
my_pread()
- Filedes File decsriptor
+ Filedes File descriptor
Buffer Buffer to read data into
Count Number of bytes to read
offset Position to read from
@@ -108,7 +108,7 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset,
SYNOPSIOS
my_pwrite()
- Filedes File decsriptor
+ Filedes File descriptor
Buffer Buffer to write data from
Count Number of bytes to write
offset Position to write to
diff --git a/mysys/my_redel.c b/mysys/my_redel.c
index 976fc5a18c345..9091c74e6b5a8 100644
--- a/mysys/my_redel.c
+++ b/mysys/my_redel.c
@@ -32,10 +32,10 @@ struct utimbuf {
/*
Rename with copy stat form old file
- Copy stats from old file to new file, deletes orginal and
+ Copy stats from old file to new file, deletes original and
changes new file name to old file name
- if MY_REDEL_MAKE_COPY is given, then the orginal file
+ if MY_REDEL_MAKE_COPY is given, then the original file
is renamed to org_name-'current_time'.BAK
*/
diff --git a/mysys/my_symlink2.c b/mysys/my_symlink2.c
index fcaf78ccff629..e2cc641ebec82 100644
--- a/mysys/my_symlink2.c
+++ b/mysys/my_symlink2.c
@@ -17,7 +17,7 @@
/*
Advanced symlink handling.
This is used in MyISAM to let users symlinks tables to different disk.
- The main idea with these functions is to automaticly create, delete and
+ The main idea with these functions is to automatically create, delete and
rename files and symlinks like they would be one unit.
*/
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index 1e4b85583b1f2..5234010ac385c 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -262,7 +262,7 @@ my_bool my_thread_init(void)
my_bool error=0;
if (!my_thread_global_init_done)
- return 1; /* cannot proceed with unintialized library */
+ return 1; /* cannot proceed with uninitialized library */
#ifdef EXTRA_DEBUG_THREADS
fprintf(stderr,"my_thread_init(): pthread_self: %p\n", pthread_self());
diff --git a/mysys/my_windac.c b/mysys/my_windac.c
index 51fe22e8f59b7..9b48975962582 100644
--- a/mysys/my_windac.c
+++ b/mysys/my_windac.c
@@ -33,7 +33,7 @@ static my_bool is_nt()
}
/*
- Auxilary structure to store pointers to the data which we need to keep
+ Auxiliary structure to store pointers to the data which we need to keep
around while SECURITY_ATTRIBUTES is in use.
*/
diff --git a/mysys/my_winerr.c b/mysys/my_winerr.c
index 15f52dd7f3752..92e1fa83d7880 100644
--- a/mysys/my_winerr.c
+++ b/mysys/my_winerr.c
@@ -117,7 +117,7 @@ static int get_errno_from_oserr(unsigned long oserrno)
return EINVAL;
}
-/* Set errno corresponsing to GetLastError() value */
+/* Set errno corresponding to GetLastError() value */
void my_osmaperr ( unsigned long oserrno)
{
errno= get_errno_from_oserr(oserrno);
diff --git a/mysys/queues.c b/mysys/queues.c
index 418163d7c581f..5d09ce2063ff5 100644
--- a/mysys/queues.c
+++ b/mysys/queues.c
@@ -27,7 +27,7 @@
This code originates from the Unireg project.
Code for generell handling of priority Queues.
- Implemention of queues from "Algoritms in C" by Robert Sedgewick.
+ Implementation of queues from "Algorithms in C" by Robert Sedgewick.
The queue can optionally store the position in queue in the element
that is in the queue. This allows one to remove any element from the queue
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index 8990cbd5a1491..45376f7c5fc82 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -528,8 +528,8 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
One can use this to signal when a thread is going to wait for a lock.
See debug_sync.cc.
- Beware of waiting for a signal here. The lock has aquired its mutex.
- While waiting on a signal here, the locking thread could not aquire
+ Beware of waiting for a signal here. The lock has acquired its mutex.
+ While waiting on a signal here, the locking thread could not acquire
the mutex to release the lock. One could lock up the table
completely.
@@ -799,8 +799,8 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner, ulong lock_wait_timeout)
\ = READ
- + = Request can be satisified.
- - = Request cannot be satisified.
+ + = Request can be satisfied.
+ - = Request cannot be satisfied.
READ_NO_INSERT and WRITE_ALLOW_WRITE should in principle
be incompatible. However this will cause starvation of
@@ -1257,7 +1257,7 @@ static void wake_up_waiters(THR_LOCK *lock)
/*
Get all locks in a specific order to avoid dead-locks
- Sort acording to lock position and put write_locks before read_locks if
+ Sort according to lock position and put write_locks before read_locks if
lock on same lock. Locks on MERGE tables has lower priority than other
locks of the same type. See comment for lock_priority.
*/
diff --git a/mysys/tree.c b/mysys/tree.c
index ab810c64c6766..5eaeb30037de4 100644
--- a/mysys/tree.c
+++ b/mysys/tree.c
@@ -30,8 +30,8 @@
3) if key_size is given to init_tree then each node will continue the
key and calls to insert_key may increase length of key.
if key_size > sizeof(pointer) and key_size is a multiple of 8 (double
- allign) then key will be put on a 8 alligned adress. Else
- the key will be on adress (element+1). This is transparent for user
+ align) then key will be put on a 8 aligned address. Else
+ the key will be on address (element+1). This is transparent for user
compare and search functions uses a pointer to given key-argument.
- If you use a free function for tree-elements and you are freeing
diff --git a/mysys/typelib.c b/mysys/typelib.c
index 75744a65ec879..96842b1a3ad6d 100644
--- a/mysys/typelib.c
+++ b/mysys/typelib.c
@@ -182,7 +182,7 @@ const char *get_type(TYPELIB *typelib, uint nr)
/**
- Create an integer value to represent the supplied comma-seperated
+ Create an integer value to represent the supplied comma-separated
string where each string in the TYPELIB denotes a bit position.
@param x string to decompose
diff --git a/mysys/waiting_threads.c b/mysys/waiting_threads.c
index ae0ffe7f7eb3a..9951403e01762 100644
--- a/mysys/waiting_threads.c
+++ b/mysys/waiting_threads.c
@@ -136,7 +136,7 @@
Status
^^^^^^
- We calculate the number of successfull waits (WT_OK returned from
+ We calculate the number of successful waits (WT_OK returned from
wt_thd_cond_timedwait()), a number of timeouts, a deadlock cycle
length distribution - number of deadlocks with every length from
1 to WT_CYCLE_STATS, and a wait time distribution - number
diff --git a/mysys/wqueue.c b/mysys/wqueue.c
index 2fcced14f771f..8d8f7a8332d83 100644
--- a/mysys/wqueue.c
+++ b/mysys/wqueue.c
@@ -211,7 +211,7 @@ void wqueue_release_one_locktype_from_queue(WQUEUE *wqueue)
/*
Add thread and wait
- SYNOPSYS
+ SYNOPSIS
wqueue_add_and_wait()
wqueue queue to add to
thread thread which is waiting
diff --git a/plugin/auth_gssapi/README.md b/plugin/auth_gssapi/README.md
index 7f678400f0d7f..ea8deaafa942e 100644
--- a/plugin/auth_gssapi/README.md
+++ b/plugin/auth_gssapi/README.md
@@ -108,7 +108,7 @@ mysql --plugin-dir=/path/to/plugin-dir -u usr1
- **gssapi-mech-name** (Windows only) - Name of the SSPI package used by server. Can be either 'Kerberos' or 'Negotiate'.
Defaults to 'Negotiate' (both Kerberos and NTLM users can connect)
Set it to 'Kerberos', to prevent less secure NTLM in domain environments, but leave it as default(Negotiate)
- to allow non-domain environment (e.g if server does not run in domain enviroment).
+ to allow non-domain environment (e.g if server does not run in domain environment).
#Implementation
@@ -124,6 +124,6 @@ Send resulting GSSAPI blob to server.
3. Server : receive blob from client, execute ```gss_accept_sec_context()/ AcceptSecurityContext()```, send resulting blob back to client
-4. Perform 2. and 3. can until both client and server decide that authentication is done, or until some error occured. If authentication was successful, GSSAPI context (an opaque structure) is generated on both client and server sides.
+4. Perform 2. and 3. can until both client and server decide that authentication is done, or until some error occurred. If authentication was successful, GSSAPI context (an opaque structure) is generated on both client and server sides.
5. Server : Client name is extracted from the context, and compared to the name provided by client(with or without realm). If name matches, plugin returns success.
diff --git a/plugin/auth_pam/mapper/pam_user_map.c b/plugin/auth_pam/mapper/pam_user_map.c
index b4db8ece06e9a..e62be946c4a95 100644
--- a/plugin/auth_pam/mapper/pam_user_map.c
+++ b/plugin/auth_pam/mapper/pam_user_map.c
@@ -6,7 +6,7 @@
gcc pam_user_map.c -shared -lpam -fPIC -o pam_user_map.so
Install as appropriate (for example, in /lib/security/).
- Add to your /etc/pam.d/mysql (preferrably, at the end) this line:
+ Add to your /etc/pam.d/mysql (preferably, at the end) this line:
=========================================================
auth required pam_user_map.so
=========================================================
@@ -15,7 +15,7 @@ auth required pam_user_map.so
in the format: orig_user_name: mapped_user_name
@user's_group_name: mapped_user_name
=========================================================
-#comments and emtpy lines are ignored
+#comments and empty lines are ignored
john: jack
bob: admin
top: accounting
diff --git a/plugin/aws_key_management/CMakeLists.txt b/plugin/aws_key_management/CMakeLists.txt
index 0e6c9b648ad1a..62d359569c6e6 100644
--- a/plugin/aws_key_management/CMakeLists.txt
+++ b/plugin/aws_key_management/CMakeLists.txt
@@ -10,7 +10,7 @@
# Give message why the building this plugin is skipped (only if -DVERBOSE is defined)
-# or if plugin is explicitely requested to build. Then bail out.
+# or if plugin is explicitly requested to build. Then bail out.
MACRO(SKIP_AWS_PLUGIN msg)
IF(VERBOSE OR "${PLUGIN_AWS_KEY_MANAGEMENT}" MATCHES "^(STATIC|DYNAMIC)$")
MESSAGE(STATUS "Can't build aws_key_management - ${msg}")
diff --git a/plugin/server_audit/plugin_audit_v4.h b/plugin/server_audit/plugin_audit_v4.h
index 5f8e43b3811c4..f8662c23e6b49 100644
--- a/plugin/server_audit/plugin_audit_v4.h
+++ b/plugin/server_audit/plugin_audit_v4.h
@@ -232,7 +232,7 @@ struct mysql_event_parse
/** input: the original query text */
MYSQL_LEX_CSTRING query;
- /** output: returns the null-terminated rewriten query allocated by my_malloc() */
+ /** output: returns the null-terminated rewritten query allocated by my_malloc() */
MYSQL_LEX_CSTRING *rewritten_query;
};
diff --git a/plugin/win_auth_client/handshake_client.cc b/plugin/win_auth_client/handshake_client.cc
index e3435f19de61f..856dda762174e 100644
--- a/plugin/win_auth_client/handshake_client.cc
+++ b/plugin/win_auth_client/handshake_client.cc
@@ -216,7 +216,7 @@ int Handshake_client::write_packet(Blob &data)
an empty blob is returned and @c error() gives non-zero error code.
When invoked for the first time (in the first round of the handshake)
- there is no data from the server (data blob is null) and the intial
+ there is no data from the server (data blob is null) and the initial
packet is generated without an input.
@return Data to be sent to the server next or null blob if no more data
diff --git a/support-files/MacOSX/ReadMe.txt b/support-files/MacOSX/ReadMe.txt
index d81ec1f66d6e6..8b833049ad4bb 100644
--- a/support-files/MacOSX/ReadMe.txt
+++ b/support-files/MacOSX/ReadMe.txt
@@ -110,7 +110,7 @@ Note
Continue .
5. If you have downloaded the community version of MySQL, you
- will be shown a copy of the relevent GNU General Public
+ will be shown a copy of the relevant GNU General Public
License. Click Continue .
6. Select the drive you want to use to install the MySQL Startup
@@ -128,7 +128,7 @@ Note
will be given an Install Succeeded message.
Once you have completed the basic installation, you must complete
- the post-installation steps as specifed in Section 2.13,
+ the post-installation steps as specified in Section 2.13,
"Post-Installation Setup and Testing."
For convenience, you may also want to install the Section 2.7.2,
diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp
index 68f1470b214e1..44f122d94732f 100644
--- a/support-files/compiler_warnings.supp
+++ b/support-files/compiler_warnings.supp
@@ -153,7 +153,7 @@ include/pwdbased\.hpp: comparison of unsigned expression
# OpenSSL
#
# The following comes because of different prototype between yassl and openssl.
-# Save as the argument is a function withing the library.
+# Save as the argument is a function within the library.
vio/viosslfactories\.c: discards ~const~ qualifier from pointer target type
#
diff --git a/support-files/mariadb.service.in b/support-files/mariadb.service.in
index 15f41c6377f64..473f269986623 100644
--- a/support-files/mariadb.service.in
+++ b/support-files/mariadb.service.in
@@ -136,7 +136,7 @@ LimitNOFILE=16364
# Timezone. previously [mysqld_safe] timezone
# Environment="TZ=UTC"
-# Library substitutions. previously [mysqld_safe] malloc-lib with explict paths
+# Library substitutions. previously [mysqld_safe] malloc-lib with explicit paths
# (in LD_LIBRARY_PATH) and library name (in LD_PRELOAD).
# Environment="LD_LIBRARY_PATH=/path1 /path2" "LD_PRELOAD=
diff --git a/support-files/mariadb@.service.in b/support-files/mariadb@.service.in
index e941f21526eb3..1041933e3ec0b 100644
--- a/support-files/mariadb@.service.in
+++ b/support-files/mariadb@.service.in
@@ -1,4 +1,4 @@
-# Multi instance version of mariadb. For if you run mutiple verions at once.
+# Multi instance version of mariadb. For if you run multiple versions at once.
# Also used for mariadb@bootstrap to bootstrap Galera.
#
# create config file @INSTALL_SYSCONF2DIR@/my{instancename}.cnf
@@ -157,7 +157,7 @@ LimitNOFILE=16364
# Timezone. previously [mysqld_safe] timezone
# Environment="TZ=UTC"
-# Library substitutions. previously [mysqld_safe] malloc-lib with explict paths
+# Library substitutions. previously [mysqld_safe] malloc-lib with explicit paths
# (in LD_LIBRARY_PATH) and library name (in LD_PRELOAD).
# Environment="LD_LIBRARY_PATH=/path1 /path2" "LD_PRELOAD=
diff --git a/support-files/my-innodb-heavy-4G.cnf.sh b/support-files/my-innodb-heavy-4G.cnf.sh
index d934b23cf0d37..2590ff5ddead8 100644
--- a/support-files/my-innodb-heavy-4G.cnf.sh
+++ b/support-files/my-innodb-heavy-4G.cnf.sh
@@ -306,7 +306,7 @@ server-id = 1
# Make the slave read-only. Only users with the SUPER privilege and the
# replication slave thread will be able to modify data on it. You can
-# use this to ensure that no applications will accidently modify data on
+# use this to ensure that no applications will accidentally modify data on
# the slave instead of the master
#read_only
@@ -439,7 +439,7 @@ innodb_log_files_in_group = 3
#innodb_log_group_home_dir
# Maximum allowed percentage of dirty pages in the InnoDB buffer pool.
-# If it is reached, InnoDB will start flushing them out agressively to
+# If it is reached, InnoDB will start flushing them out aggressively to
# not run out of clean pages at all. This is a soft limit, not
# guaranteed to be held.
innodb_max_dirty_pages_pct = 90
diff --git a/support-files/mysql-multi.server.sh b/support-files/mysql-multi.server.sh
index a036374a4b2e9..f90d662fa8c72 100644
--- a/support-files/mysql-multi.server.sh
+++ b/support-files/mysql-multi.server.sh
@@ -12,7 +12,7 @@
# started and shut down when the systems goes down. The '.svr1' suffix can
# be used to identify one of a number of servers. Multiple symlinks can be
# created, one per instance. The 'svrN' suffix can then be used to
-# prefix configuration variables in a seperate section of /etc/my.cnf.
+# prefix configuration variables in a separate section of /etc/my.cnf.
# See example below.
#
# A typical multi-instance /etc/my.cnf file would look like:
diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh
index 28bfd19be6027..0e4538dc2ccbb 100644
--- a/support-files/mysql.server.sh
+++ b/support-files/mysql.server.sh
@@ -48,7 +48,7 @@ datadir=
# Default value, in seconds, afterwhich the script should timeout waiting
# for server start.
-# Value here is overriden by value in my.cnf.
+# Value here is overridden by value in my.cnf.
# 0 means don't wait at all
# Negative numbers mean to wait indefinitely
service_startup_timeout=900
From dbd1d7ea8e96a2b4cff89ec889494700d634b3a3 Mon Sep 17 00:00:00 2001
From: Jean Weisbuch
Date: Mon, 23 Jan 2017 11:58:41 +0100
Subject: [PATCH 139/226] Updated innotop on debian/additions from 1.7.1 to
1.11.4
---
debian/additions/innotop/changelog.innotop | 84 +
debian/additions/innotop/innotop | 1906 +++++++++++++++++---
debian/additions/innotop/innotop.1 | 488 +++--
3 files changed, 1993 insertions(+), 485 deletions(-)
diff --git a/debian/additions/innotop/changelog.innotop b/debian/additions/innotop/changelog.innotop
index ab4c154d6e6e4..67bc52698e764 100644
--- a/debian/additions/innotop/changelog.innotop
+++ b/debian/additions/innotop/changelog.innotop
@@ -1,10 +1,94 @@
Changelog for innotop:
+2017-01-20: version 1.11.4
+ * add SUM function for ONLY_FULL_GROUP_BY
+
+2017-01-20: version 1.11.3
+
+ * Undisplay handlersocket's threads in hide_inactive
+ * fix runtime error regarding redundant sprintf argument #122
+ * added sort on connection-name in display M, after sql/io running, seconds behind master and channel_name
+ * fixed bug that removed value for cxn and channel_name columns in display M
+ * added sort on replication delay, so that the replication-display will sort on slave_sql_running, timelag (in minutes) and channel_name.
+ * support for MariaDB 10.0 in InnoDB row (issue 93)
+
+2013-07-12: version 1.9.1
+
+ Bugs fixed:
+ * Support of MySQL 5.6 was broken on some pages (issue 82, 83)
+ * Deadlock clearing transactions is now not included in binary log
+ (issue 84)
+ * New spec file with requirements and build requirements for
+ CentOS/RHEL and Fedora
+
+2012-09-07: version 1.9.0
+
+ Changes:
+ * A new Health Dashboard (A) mode is the default mode.
+ * Added a new InnoDB Locked (K) mode.
+ * Added a new 'spark' config variable for sparklines.
+ * Added a new fuzzy_time formatting function.
+ * Added "query distill" summarizing.
+ * Handled more types of errors connecting to the server.
+ * Displayed some data more compactly.
+
+ Bugs fixed:
+ * Double-quotes were used to terminate strings in SQL (issue 57).
+ * T mode didn't show InnoDB transaction times (issue 67).
+ * Killing a query didn't suggest the longest-running one automatically.
+ * Connections weren't closed on exit (issue 64).
+ * Q mode didn't have connections in its header (issue 63).
+ * Connections and server groups were poorly handled (issue 68).
+ * The RPM spec file was buggy (issue 59).
+ * Event filters were defined wrong (issue 54).
+
+2012-02-25: version 1.8.1
+
+ Bugs fixed:
+ * Various parsing errors with MySQL 5.5 (issue 23, 45, 47, 51, 52, 53).
+ * RPM spec file prevented building on CentOS 5.5 using mock (issue 44).
+ * Tests worked only from the test subdirectory (issue 43).
+
+2010-11-06: version 1.8.0
+
+ Changes:
+ * Don't re-fetch SHOW VARIABLES every iteration; it's too slow on many hosts.
+ * Add a filter to remove EVENT threads in SHOW PROCESSLIST (issue 32).
+ * Add a timestamp to output in -n mode, when -t is specified (issue 37).
+ * Add a new U mode, for Percona/MariaDB USER_STATISTICS (issue 39).
+ * Add support for millisecond query time in Percona Server (issue 39).
+ * Display a summary of queries executed in Query List mode (issue 26).
+
+ Bugs fixed:
+ * Made config-file reading more robust (issue 41).
+ * Hostname parsing wasn't standards compliant (issue 30).
+ * MKDEBUG didn't work on some Perl versions (issue 22).
+ * Don't try to get InnoDB status if have_innodb != YES (issue 33).
+ * Status text from the InnoDB plugin wasn't parsed correctly (issue 36).
+ * Transaction ID from InnoDB plugin wasn't subtracted correctly (issue 38).
+ * Switching modes and pressing ? for help caused a crash (issue 40).
+
+2009-09-06: version 1.7.2
+
+ Changes:
+ * add support for --socket
+
+ Bugs fixed:
+ * remove cxn from $meta->{group_by} if there's only one connection displayed
+ * fix for issue 19 - cxn column won't become visible when viewing two
+ connections after having viewed one connection
+ * supress errors resulting from the addition of a 'BACKGROUND THREAD'
+ section in the output of 'show innodb status'
+ * possible fix for issue 22 - Useless use of a constant in void context
+ * small change to set_to_tbl() around hiding the cxn column if there
+ aren't two or more connections
+
2009-03-09: version 1.7.1
Changes:
* Don't display the CXN column if only one connection is active in
the current view
+ * the 'state' column is now visible by default in Query List mode
Bugs fixed:
* fixed bug where trying to aggregate the time column would result
diff --git a/debian/additions/innotop/innotop b/debian/additions/innotop/innotop
index 9179a0d7a81a2..f958eba432b63 100644
--- a/debian/additions/innotop/innotop
+++ b/debian/additions/innotop/innotop
@@ -1,8 +1,9 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
# vim: tw=160:nowrap:expandtab:tabstop=3:shiftwidth=3:softtabstop=3
# This program is copyright (c) 2006 Baron Schwartz, baron at xaprb dot com.
+# Maintainers since 2013 : Kenny Gryp - Frédéric Descamps
# Feedback and improvements are gratefully received.
#
# THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
@@ -15,13 +16,13 @@
# systems, you can issue `man perlgpl' or `man perlartistic' to read these
# 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., 59 Temple
-# Place, Suite 330, Boston, MA 02111-1307 USA
+# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
+# Street, Fifth Floor, Boston, MA 02110-1301 USA
use strict;
use warnings FATAL => 'all';
-our $VERSION = '1.7.1';
+our $VERSION = '1.11.4';
# Find the home directory; it's different on different OSes.
our $homepath = $ENV{HOME} || $ENV{HOMEPATH} || $ENV{USERPROFILE} || '.';
@@ -41,7 +42,7 @@ $Data::Dumper::Indent = 0;
$Data::Dumper::Quotekeys = 0;
use English qw(-no_match_vars);
-use constant MKDEBUG => $ENV{MKDEBUG};
+use constant MKDEBUG => $ENV{MKDEBUG} || 0;
# Defaults are built-in, but you can add/replace items by passing them as
# hashrefs of {key, desc, copy, dsn}. The desc and dsn items are optional.
@@ -93,7 +94,9 @@ sub new {
},
};
foreach my $opt ( @opts ) {
- MKDEBUG && _d('Adding extra property ' . $opt->{key});
+ if (MKDEBUG) {
+ _d('Adding extra property ' . $opt->{key});
+ }
$self->{opts}->{$opt->{key}} = { desc => $opt->{desc}, copy => $opt->{copy} };
}
return bless $self, $class;
@@ -356,17 +359,18 @@ use Data::Dumper;
$Data::Dumper::Sortkeys = 1;
use English qw(-no_match_vars);
use List::Util qw(max);
+use POSIX qw(strftime);
# Some common patterns
my $d = qr/(\d+)/; # Digit
my $f = qr/(\d+\.\d+)/; # Float
-my $t = qr/(\d+ \d+)/; # Transaction ID
+my $t = qr/((?:\d+ \d+)|(?:[A-Fa-f0-9]+))/; # Transaction ID
my $i = qr/((?:\d{1,3}\.){3}\d+)/; # IP address
my $n = qr/([^`\s]+)/; # MySQL object name
my $w = qr/(\w+)/; # Words
my $fl = qr/([\w\.\/]+) line $d/; # Filename and line number
my $h = qr/((?:0x)?[0-9a-f]*)/; # Hex
-my $s = qr/(\d{6} .\d:\d\d:\d\d)/; # InnoDB timestamp
+my $s = qr/(\d{6} .?\d:\d\d:\d\d)/; # InnoDB timestamp
# If you update this variable, also update the SYNOPSIS in the pod.
my %innodb_section_headers = (
@@ -379,6 +383,7 @@ my %innodb_section_headers = (
"FILE I/O" => "io",
"LATEST DETECTED DEADLOCK" => "dl",
"LATEST FOREIGN KEY ERROR" => "fk",
+ "BACKGROUND THREAD" => "bt",
);
my %parser_for = (
@@ -442,7 +447,7 @@ sub new {
# to parse (hashref; if empty, parse all), and whether to parse full info from
# locks and such (probably shouldn't unless you need to).
sub parse_status_text {
- my ( $self, $fulltext, $debug, $sections, $full ) = @_;
+ my ( $self, $fulltext, $debug, $sections, $full, $mysqlversion ) = @_;
die "I can't parse undef" unless defined $fulltext;
$fulltext =~ s/[\r\n]+/\n/g;
@@ -464,8 +469,16 @@ sub parse_status_text {
# Get the most basic info about the status: beginning and end, and whether
# I got the whole thing (if there has been a big deadlock and there are
# too many locks to print, the output might be truncated)
- my ( $time_text ) = $fulltext =~ m/^$s INNODB MONITOR OUTPUT$/m;
- $innodb_data{'ts'} = [ parse_innodb_timestamp( $time_text ) ];
+
+ my $time_text;
+ if ( ($mysqlversion =~ /^5\.[67]\./) || ($mysqlversion =~ /^10\.[012]\./) ) {
+ ( $time_text ) = $fulltext =~ m/^([0-9-]* [0-9:]*) [0-9a-fx]* INNODB MONITOR OUTPUT/m;
+ $innodb_data{'ts'} = [ parse_innodb_timestamp_56( $time_text ) ];
+ } else {
+ ( $time_text ) = $fulltext =~ m/^$s INNODB MONITOR OUTPUT$/m;
+ $innodb_data{'ts'} = [ parse_innodb_timestamp( $time_text ) ];
+ }
+
$innodb_data{'timestring'} = ts_to_string($innodb_data{'ts'});
( $innodb_data{'last_secs'} ) = $fulltext
=~ m/Per second averages calculated from the last $d seconds/;
@@ -483,22 +496,34 @@ sub parse_status_text {
while ( my ( $start, $name, $text, $end ) = splice(@matches, 0, 4) ) {
$innodb_sections{$name} = [ $text, $end ? 1 : 0 ];
}
- # The Row Operations section is a special case, because instead of ending
- # with the beginning of another section, it ends with the end of the file.
- # So this section is complete if the entire file is complete.
- $innodb_sections{'ROW OPERATIONS'}->[1] ||= $innodb_data{'got_all'};
# Just for sanity's sake, make sure I understand what to do with each
- # section
+ # section.
eval {
foreach my $section ( keys %innodb_sections ) {
my $header = $innodb_section_headers{$section};
- die "Unknown section $section in $fulltext\n"
- unless $header;
- $innodb_data{'sections'}->{ $header }
- ->{'fulltext'} = $innodb_sections{$section}->[0];
- $innodb_data{'sections'}->{ $header }
- ->{'complete'} = $innodb_sections{$section}->[1];
+ if ( !$header && $debug ) {
+ warn "Unknown section $section in $fulltext\n";
+ }
+
+ # The last section in the file is a special case, because instead of
+ # ending with the beginning of another section, it ends with the end of
+ # the file. So this section is complete if the entire file is
+ # complete. In different versions of InnoDB, various sections are
+ # last.
+ if ( $innodb_sections{$section}->[0] =~ s/\n---+\nEND OF INNODB.+\n=+$// ) {
+ $innodb_sections{$section}->[1] ||= $innodb_data{'got_all'};
+ }
+
+ if ( $header && $section ) {
+ $innodb_data{'sections'}->{ $header }
+ ->{'fulltext'} = $innodb_sections{$section}->[0];
+ $innodb_data{'sections'}->{ $header }
+ ->{'complete'} = $innodb_sections{$section}->[1];
+ }
+ else {
+ _debug( $debug, "header = " . ($header || 'undef') . ", section = " . ($section || 'undef')) if $debug;
+ }
}
};
if ( $EVAL_ERROR ) {
@@ -516,7 +541,8 @@ sub parse_status_text {
$innodb_data{'sections'}->{$section},
$innodb_data{'sections'}->{$section}->{'complete'},
$debug,
- $full )
+ $full,
+ $mysqlversion)
or delete $innodb_data{'sections'}->{$section};
}
else {
@@ -533,11 +559,11 @@ sub parse_status_text {
# Parses the status text and returns it flattened out as a single hash.
sub get_status_hash {
- my ( $self, $fulltext, $debug, $sections, $full ) = @_;
+ my ( $self, $fulltext, $debug, $sections, $full, $mysqlversion ) = @_;
# Parse the status text...
my $innodb_status
- = $self->parse_status_text($fulltext, $debug, $sections, $full );
+ = $self->parse_status_text($fulltext, $debug, $sections, $full, $mysqlversion );
# Flatten the hierarchical structure into a single list by grabbing desired
# sections from it.
@@ -598,14 +624,29 @@ sub parse_innodb_timestamp {
return ( $y, $m, $d, $h, $i, $s );
}
+sub parse_innodb_timestamp_56 {
+ my $text = shift;
+ my ( $y, $m, $d, $h, $i, $s )
+ = $text =~ m/^(\d\d\d\d)-(\d\d)-(\d\d) +(\d+):(\d+):(\d+)$/;
+ die("Can't get timestamp from $text\n") unless $y;
+ return ( $y, $m, $d, $h, $i, $s );
+}
+
sub parse_fk_section {
- my ( $section, $complete, $debug, $full ) = @_;
+ my ( $section, $complete, $debug, $full, $mysqlversion ) = @_;
my $fulltext = $section->{'fulltext'};
return 0 unless $fulltext;
- my ( $ts, $type ) = $fulltext =~ m/^$s\s+(\w+)/m;
- $section->{'ts'} = [ parse_innodb_timestamp( $ts ) ];
+ my ( $ts, $type );
+ if ( ($mysqlversion =~ /^5.[67]\./) || ($mysqlversion =~ /^10.[012]\./) ) {
+ ( $ts, $type ) = $fulltext =~ m/^([0-9-]* [0-9:]*)\s[0-9a-fx]*\s+(\w+)/m;
+ $section->{'ts'} = [ parse_innodb_timestamp_56( $ts ) ];
+ } else {
+ ( $ts, $type ) = $fulltext =~ m/^$s\s+(\w+)/m;
+ $section->{'ts'} = [ parse_innodb_timestamp( $ts ) ];
+ }
+
$section->{'timestring'} = ts_to_string($section->{'ts'});
$section->{'type'} = $type;
@@ -629,6 +670,9 @@ sub parse_fk_cant_drop_parent_error {
=~ m{because it is referenced by `(.*)/(.*)`}m;
( $section->{'reason'} ) = $fulltext =~ m/(Cannot .*)/s;
+ if ( !defined $section->{reason} ) {
+ ( $section->{'reason'} ) = $fulltext =~ m/(Trying to add .*)/s;
+ }
$section->{'reason'} =~ s/\n(?:InnoDB: )?/ /gm
if $section->{'reason'};
@@ -699,7 +743,7 @@ sub parse_fk_transaction_error {
# no matching parent record (row_ins_foreign_report_add_err).
@{$section}{ qw(reason child_db child_table) }
- = $fulltext =~ m{^(Foreign key constraint fails for table `(.*)/(.*)`:)$}m;
+ = $fulltext =~ m{^(Foreign key constraint fails for table `(.*?)`?[/.]`?(.*)`:)$}m;
@{$section}{ qw(fk_name col_name parent_db parent_table parent_col) }
= $fulltext
@@ -847,7 +891,7 @@ sub parse_field {
}
sub parse_dl_section {
- my ( $dl, $complete, $debug, $full ) = @_;
+ my ( $dl, $complete, $debug, $full, $mysqlversion ) = @_;
return unless $dl;
my $fulltext = $dl->{'fulltext'};
return 0 unless $fulltext;
@@ -855,7 +899,12 @@ sub parse_dl_section {
my ( $ts ) = $fulltext =~ m/^$s$/m;
return 0 unless $ts;
- $dl->{'ts'} = [ parse_innodb_timestamp( $ts ) ];
+ if ( ($mysqlversion =~ /^5\.[67]\./) || ($mysqlversion =~ /^10\.[012]\./) ) {
+ $dl->{'ts'} = [ parse_innodb_timestamp_56( $ts ) ];
+ }
+ else {
+ $dl->{'ts'} = [ parse_innodb_timestamp( $ts ) ];
+ }
$dl->{'timestring'} = ts_to_string($dl->{'ts'});
$dl->{'txns'} = {};
@@ -923,12 +972,22 @@ sub parse_innodb_record_locks {
sub parse_tx_text {
my ( $txn, $complete, $debug, $full ) = @_;
- my ( $txn_id, $txn_status, $active_secs, $proc_no, $os_thread_id )
+ my ( $txn_id, $txn_status )
= $txn
- =~ m/^(?:---)?TRANSACTION $t, (\D*?)(?: $d sec)?, (?:process no $d, )?OS thread id $d/m;
+ =~ m/^(?:---)?TRANSACTION $t, ([^\n0-9,]*[^\s\d])/m;
+ $txn_status =~ s/,$// if $txn_status;
+ my ( $active_secs)
+ = $txn
+ =~ m/^[^\n]*\b$d sec\b/m;
+ my ( $proc_no )
+ = $txn
+ =~ m/process no $d/m;
+ my ( $os_thread_id )
+ = $txn
+ =~ m/OS thread id $d/m;
my ( $thread_status, $thread_decl_inside )
= $txn
- =~ m/OS thread id \d+(?: ([^,]+?))?(?:, thread declared inside InnoDB $d)?$/m;
+ =~ m/(?:OS thread id \d+|\d sec)(?: ([^,]+?))?(?:, thread declared inside InnoDB $d)?$/m;
# Parsing the line that begins 'MySQL thread id' is complicated. The only
# thing always in the line is the thread and query id. See function
@@ -938,7 +997,7 @@ sub parse_tx_text {
if ( $thread_line ) {
# These parts can always be gotten.
- ( $mysql_thread_id, $query_id ) = $thread_line =~ m/^MySQL thread id $d, query id $d/m;
+ ( $mysql_thread_id, $query_id ) = $thread_line =~ m/^MySQL thread id $d, .*?query id $d/m;
# If it's a master/slave thread, "Has (read|sent) all" may be the thread's
# proc_info. In these cases, there won't be any host/ip/user info
@@ -963,6 +1022,11 @@ sub parse_tx_text {
# It's basically impossible to know which is which.
( $hostname, $user, $query_status ) = $thread_line
=~ m/query id \d+(?: ([A-Za-z]\S+))?(?: $w(?: (.*))?)?$/m;
+ if ( ($hostname || '') eq 'Slave' ) {
+ $hostname = '';
+ $user = 'system user';
+ $query_status = "Slave has $query_status";
+ }
}
else {
$user = 'system user';
@@ -1064,7 +1128,7 @@ sub parse_tx_section {
$section->{'transactions'} = [];
# Handle the individual transactions
- my @transactions = $fulltext =~ m/(---TRANSACTION \d.*?)(?=\n---TRANSACTION|$)/gs;
+ my @transactions = $fulltext =~ m/(---TRANSACTION [0-9A-Fa-f].*?)(?=\n---TRANSACTION|$)/gs;
foreach my $txn ( @transactions ) {
my $stuff = parse_tx_text( $txn, $complete, $debug, $full );
delete $stuff->{'fulltext'} unless $debug;
@@ -1131,7 +1195,7 @@ sub parse_lg_section {
( $section->{ 'last_chkp' } )
= $fulltext =~ m/Last checkpoint at \s*(\d.*)$/m;
@{$section}{ 'pending_log_writes', 'pending_chkp_writes' }
- = $fulltext =~ m/$d pending log writes, $d pending chkp writes/;
+ = $fulltext =~ m/$d pending log (?:writes|flushes), $d pending chkp writes/;
@{$section}{ 'log_ios_done', 'log_ios_s' }
= $fulltext =~ m#$d log i/o's done, $f log i/o's/second#;
@@ -1149,12 +1213,19 @@ sub parse_ib_section {
# the source code shows there will only ever be one). I have to parse both
# cases here, but I assume there will only be one.
@{$section}{ 'size', 'free_list_len', 'seg_size' }
- = $fulltext =~ m/^Ibuf(?: for space 0)?: size $d, free list len $d, seg size $d,$/m;
+ = $fulltext =~ m/^Ibuf(?: for space 0)?: size $d, free list len $d, seg size $d/m;
@{$section}{ 'inserts', 'merged_recs', 'merges' }
= $fulltext =~ m/^$d inserts, $d merged recs, $d merges$/m;
+ if ( ! defined $section->{inserts} ) {
+ @{$section}{ 'inserts' }
+ = $fulltext =~ m/merged operations:\n insert $d,/s;
+ # This isn't really true, but it's not really important either. We already
+ # aren't supporting the 'delete' operations.
+ @{$section}{ 'merged_recs', 'merges' } = (0, 0);
+ }
@{$section}{ 'hash_table_size', 'used_cells', 'bufs_in_node_heap' }
- = $fulltext =~ m/^Hash table size $d, used cells $d, node heap has $d buffer\(s\)$/m;
+ = $fulltext =~ m/^Hash table size $d(?:, used cells $d)?, node heap has $d buffer\(s\)$/m;
@{$section}{ 'hash_searches_s', 'non_hash_searches_s' }
= $fulltext =~ m{^$f hash searches/s, $f non-hash searches/s$}m;
@@ -1215,6 +1286,12 @@ sub parse_sm_section {
= $fulltext =~ m/^Mutex spin waits $d, rounds $d, OS waits $d$/m;
@{$section}{ 'rw_shared_spins', 'rw_shared_os_waits', 'rw_excl_spins', 'rw_excl_os_waits' }
= $fulltext =~ m/^RW-shared spins $d, OS waits $d; RW-excl spins $d, OS waits $d$/m;
+ if ( ! defined $section->{rw_shared_spins} ) {
+ @{$section}{ 'rw_shared_spins', 'rw_shared_os_waits'}
+ = $fulltext =~ m/^RW-shared spins $d, rounds \d+, OS waits $d$/m;
+ @{$section}{ 'rw_excl_spins', 'rw_excl_os_waits' }
+ = $fulltext =~ m/^RW-excl spins $d, rounds \d+, OS waits $d$/m;
+ }
# Look for info on waits.
my @waits = $fulltext =~ m/^(--Thread.*?)^(?=Mutex spin|--Thread)/gms;
@@ -1245,14 +1322,14 @@ sub parse_bp_section {
@{$section}{'page_reads_sec', 'page_creates_sec', 'page_writes_sec'}
= $fulltext =~ m{^$f reads/s, $f creates/s, $f writes/s$}m;
@{$section}{'buf_pool_hits', 'buf_pool_reads'}
- = $fulltext =~ m{Buffer pool hit rate $d / $d$}m;
+ = $fulltext =~ m{Buffer pool hit rate $d / $d}m;
if ($fulltext =~ m/^No buffer pool page gets since the last printout$/m) {
@{$section}{'buf_pool_hits', 'buf_pool_reads'} = (0, 0);
@{$section}{'buf_pool_hit_rate'} = '--';
}
else {
@{$section}{'buf_pool_hit_rate'}
- = $fulltext =~ m{Buffer pool hit rate (\d+ / \d+)$}m;
+ = $fulltext =~ m{Buffer pool hit rate (\d+ / \d+)}m;
}
@{$section}{'reads_pending'} = $fulltext =~ m/^Pending reads $d/m;
@{$section}{'writes_pending_lru', 'writes_pending_flush_list', 'writes_pending_single_page' }
@@ -1292,7 +1369,7 @@ sub parse_io_section {
# Grab the reads/writes/flushes info
@{$section}{ 'pending_normal_aio_reads', 'pending_aio_writes' }
- = $fulltext =~ m/^Pending normal aio reads: $d, aio writes: $d,$/m;
+ = $fulltext =~ m/^Pending normal aio reads: $d(?: [^\]]*\])?, aio writes: $d/m;
@{$section}{ 'pending_ibuf_aio_reads', 'pending_log_ios', 'pending_sync_ios' }
= $fulltext =~ m{^ ibuf aio reads: $d, log i/o's: $d, sync i/o's: $d$}m;
@{$section}{ 'flush_type', 'pending_log_flushes', 'pending_buffer_pool_flushes' }
@@ -1393,6 +1470,7 @@ my %col_props = (
trans => [],
agg => 'first', # Aggregate function
aggonly => 0, # Whether to show only when tbl_meta->{aggregate} is true
+ agghide => 0, # Whether NOT to show when tbl_meta->{aggregate} is true
);
# Actual DBI connections to MySQL servers.
@@ -1410,13 +1488,17 @@ my @opt_spec = (
{ s => 'delay|d=f', d => 'Delay between updates in seconds', c => 'interval' },
{ s => 'mode|m=s', d => 'Operating mode to start in', c => 'mode' },
{ s => 'inc|i!', d => 'Measure incremental differences', c => 'status_inc' },
+ { s => 'spark=i', d => 'Length of status sparkline (default 10)', c=> 'spark' },
{ s => 'write|w', d => 'Write running configuration into home directory if no config files were loaded' },
{ s => 'skipcentral|s', d => 'Skip reading the central configuration file' },
{ s => 'version', d => 'Output version information and exit' },
{ s => 'user|u=s', d => 'User for login if not current user' },
{ s => 'password|p=s', d => 'Password to use for connection' },
+ { s => 'askpass', d => 'Prompt for a password when connecting to MySQL'},
{ s => 'host|h=s', d => 'Connect to host' },
{ s => 'port|P=i', d => 'Port number to use for connection' },
+ { s => 'socket|S=s', d => 'MySQL socket to use for connection' },
+ { s => 'timestamp|t+', d => 'Print timestamp in -n mode (1: per iter; 2: per line)' },
);
# This is the container for the command-line options' values to be stored in
@@ -1427,7 +1509,7 @@ my %opts = (
# Post-process...
my %opt_seen;
foreach my $spec ( @opt_spec ) {
- my ( $long, $short ) = $spec->{s} =~ m/^(\w+)(?:\|([^!+=]*))?/;
+ my ( $long, $short ) = $spec->{s} =~ m/^(\w+)(?:\|([^!+=:]*))?/;
$spec->{k} = $short || $long;
$spec->{l} = $long;
$spec->{t} = $short;
@@ -1448,6 +1530,11 @@ if ( $opts{c} and ! -f $opts{c} ) {
print $opts{c} . " doesn't exist. Exiting.\n";
exit(1);
}
+
+if ( $opts{'askpass'} ) {
+ $opts{'p'} = noecho_password("Enter password ");
+}
+
if ( $opts{'help'} ) {
print "Usage: innotop \n\n";
my $maxw = max(map { length($_->{l}) + ($_->{n} ? 4 : 0)} @opt_spec);
@@ -1468,6 +1555,14 @@ USAGE
exit(1);
}
+if ( defined($opts{p}) && length($opts{p}) == 0 ) {
+ print "Enter password: ";
+ ReadMode('noecho');
+ $opts{p} = ;
+ chomp($opts{p});
+ ReadMode('normal');
+}
+
# Meta-data (table definitions etc) {{{2
# ###########################################################################
@@ -1475,7 +1570,7 @@ USAGE
# Convenience so I can copy/paste these in several places...
# ###########################################################################
my %exprs = (
- Host => q{my $host = host || hostname || ''; ($host) = $host =~ m/^((?:[\d.]+(?=:))|(?:[a-zA-Z]\w+))/; return $host || ''},
+ Host => q{my $host = host || hostname || ''; ($host) = $host =~ m/^((?:[\d.]+(?=:|$))|(?:[a-z0-9-]+))/i; return $host || ''},
Port => q{my ($p) = host =~ m/:(.*)$/; return $p || 0},
OldVersions => q{dulint_to_int(IB_tx_trx_id_counter) - dulint_to_int(IB_tx_purge_done_for)},
MaxTxnTime => q/max(map{ $_->{active_secs} } @{ IB_tx_transactions }) || 0/,
@@ -1483,9 +1578,18 @@ my %exprs = (
DirtyBufs => q{ $cur->{IB_bp_pages_modified} / ($cur->{IB_bp_buf_pool_size} || 1) },
BufPoolFill => q{ $cur->{IB_bp_pages_total} / ($cur->{IB_bp_buf_pool_size} || 1) },
ServerLoad => q{ $cur->{Threads_connected}/(Questions||1)/Uptime_hires },
+ Connection => q{ max_connections || $cur->{Threads_connected} },
+ chcxn_2_cxn => q{ if ( defined($cur->{cxn}) ) { return $cur->{cxn}; } else { my ($cha, $conn) = split ("=",$cur->{chcxn}) ; return $conn; } },
+ chcxn_2_ch => q{ if ( defined($cur->{channel_name}) ) { return $cur->{channel_name}; } else { my ($cha, $conn) = split ("=",$cur->{chcxn}) ; $cha = '' if ($cha = /no_channels/); return $cha || 'failed'; } },
TxnTimeRemain => q{ defined undo_log_entries && defined $pre->{undo_log_entries} && undo_log_entries < $pre->{undo_log_entries} ? undo_log_entries / (($pre->{undo_log_entries} - undo_log_entries)/((active_secs-$pre->{active_secs})||1))||1 : 0},
SlaveCatchupRate => ' defined $cur->{seconds_behind_master} && defined $pre->{seconds_behind_master} && $cur->{seconds_behind_master} < $pre->{seconds_behind_master} ? ($pre->{seconds_behind_master}-$cur->{seconds_behind_master})/($cur->{Uptime_hires}-$pre->{Uptime_hires}) : 0',
QcacheHitRatio => q{(Qcache_hits||0)/(((Com_select||0)+(Qcache_hits||0))||1)},
+ QueryDetail => q{sprintf("%2d/%2d/%2d/%2d",
+ ((Com_select||0)+(Qcache_hits||0))/(Questions||1)*100,
+ ((Com_insert||0)+(Com_replace||0))/(Questions||1)*100,
+ (Com_update||0)/(Questions||1)*100,
+ (Com_delete||0)/(Questions||1)*100,
+)},
);
# ###########################################################################
@@ -1503,12 +1607,21 @@ my %exprs = (
my %columns = (
active_secs => { hdr => 'SecsActive', num => 1, label => 'Seconds transaction has been active', },
- add_pool_alloc => { hdr => 'Add\'l Pool', num => 1, label => 'Additional pool allocated' },
+ add_pool_alloc => { hdr => 'Add\'l Pool', num => 1, label => 'Additonal pool allocated' },
attempted_op => { hdr => 'Action', num => 0, label => 'The action that caused the error' },
awe_mem_alloc => { hdr => 'AWE Memory', num => 1, label => '[Windows] AWE memory allocated' },
binlog_cache_overflow => { hdr => 'Binlog Cache', num => 1, label => 'Transactions too big for binlog cache that went to disk' },
binlog_do_db => { hdr => 'Binlog Do DB', num => 0, label => 'binlog-do-db setting' },
binlog_ignore_db => { hdr => 'Binlog Ignore DB', num => 0, label => 'binlog-ignore-db setting' },
+ blocking_thread => { hdr => 'BThread', num => 1, label => 'Blocking thread' },
+ blocking_query => { hdr => 'Blocking Query', num => 0, label => 'Blocking query' },
+ blocking_rows_modified => { hdr => 'BRowsMod', num => 1, label => 'Blocking number rows modified' },
+ blocking_age => { hdr => 'BAge', num => 1, label => 'Blocking age' },
+ blocking_wait_secs => { hdr => 'BWait', num => 1, label => 'Blocking wait time' },
+ blocking_user => { hdr => 'BUser', num => 0, label => 'Blocking user' },
+ blocking_host => { hdr => 'BHost', num => 0, label => 'Blocking host' },
+ blocking_db => { hdr => 'BDB', num => 0, label => 'Blocking database' },
+ blocking_status => { hdr => 'BStatus', num => 0, label => 'Blocking thread status' },
bps_in => { hdr => 'BpsIn', num => 1, label => 'Bytes per second received by the server', },
bps_out => { hdr => 'BpsOut', num => 1, label => 'Bytes per second sent by the server', },
buf_free => { hdr => 'Free Bufs', num => 1, label => 'Buffers free in the buffer pool' },
@@ -1520,11 +1633,13 @@ my %columns = (
bytes_behind_master => { hdr => 'ByteLag', num => 1, label => 'Bytes the slave lags the master in binlog' },
cell_event_set => { hdr => 'Ending?', num => 1, label => 'Whether the cell event is set' },
cell_waiting => { hdr => 'Waiting?', num => 1, label => 'Whether the cell is waiting' },
+ channel_name => { hdr => 'Channel', num => 0, label => 'The name of the replication channel' },
child_db => { hdr => 'Child DB', num => 0, label => 'The database of the child table' },
child_index => { hdr => 'Child Index', num => 0, label => 'The index in the child table' },
child_table => { hdr => 'Child Table', num => 0, label => 'The child table' },
cmd => { hdr => 'Cmd', num => 0, label => 'Type of command being executed', },
cnt => { hdr => 'Cnt', num => 0, label => 'Count', agg => 'count', aggonly => 1 },
+ connections => { hdr => 'Cxns', num => 1, label => 'Connections' },
connect_retry => { hdr => 'Connect Retry', num => 1, label => 'Slave connect-retry timeout' },
cxn => { hdr => 'CXN', num => 0, label => 'Connection from which the data came', },
db => { hdr => 'DB', num => 0, label => 'Current database', },
@@ -1533,6 +1648,7 @@ my %columns = (
dl_txn_num => { hdr => 'Num', num => 0, label => 'Deadlocked transaction number', },
event_set => { hdr => 'Evt Set?', num => 1, label => '[Win32] if a wait event is set', },
exec_master_log_pos => { hdr => 'Exec Master Log Pos', num => 1, label => 'Exec Master Log Position' },
+ executed_gtid_set => { hdr => 'Executed GTID Set', num => 0, label => 'Executed GTID Set', },
fk_name => { hdr => 'Constraint', num => 0, label => 'The name of the FK constraint' },
free_list_len => { hdr => 'Free List Len', num => 1, label => 'Length of the free list' },
has_read_view => { hdr => 'Rd View', num => 1, label => 'Whether the transaction has a read view' },
@@ -1544,7 +1660,7 @@ my %columns = (
host_and_domain => { hdr => 'Host', num => 0, label => 'Hostname/IP and domain' },
host_and_port => { hdr => 'Host/IP', num => 0, label => 'Hostname or IP address, and port number', },
hostname => { hdr => 'Host', num => 0, label => 'Hostname' },
- index => { hdr => 'Index', num => 0, label => 'The index involved' },
+ index => { hdr => 'Index', num => 0, label => 'The index involved', agghide => 1 },
index_ref => { hdr => 'Index Ref', num => 0, label => 'Index referenced' },
info => { hdr => 'Query', num => 0, label => 'Info or the current query', },
insert_intention => { hdr => 'Ins Intent', num => 1, label => 'Whether the thread was trying to insert' },
@@ -1569,8 +1685,10 @@ my %columns = (
last_total => { hdr => 'Last Total', num => 1, label => 'Last Total' },
last_value => { hdr => 'Last Incr', num => 1, label => 'Last Value' },
load => { hdr => 'Load', num => 1, label => 'Server load' },
+ locked_count => { hdr => 'Lock', num => 1, label => 'Number of locked threads' },
lock_cfile_name => { hdr => 'Crtd File', num => 0, label => 'Filename where lock created' },
lock_cline => { hdr => 'Crtd Line', num => 1, label => 'Line where lock created' },
+ lock_info => { hdr => 'Lock Info', num => 0, label => 'Lock information' },
lock_mem_addr => { hdr => 'Addr', num => 0, label => 'The lock memory address' },
lock_mode => { hdr => 'Mode', num => 0, label => 'The lock mode' },
lock_structs => { hdr => 'LStrcts', num => 1, label => 'Number of lock structs' },
@@ -1581,6 +1699,7 @@ my %columns = (
log_ios_done => { hdr => 'IO Done', num => 1, label => 'Log I/Os done' },
log_ios_s => { hdr => 'IO/Sec', num => 1, label => 'Average log I/Os per sec' },
log_seq_no => { hdr => 'Sequence No.', num => 0, label => 'Log sequence number' },
+ longest_sql => { hdr => 'SQL', num => 0, label => 'Longest-running SQL statement' },
main_thread_id => { hdr => 'Main Thread ID', num => 1, label => 'Main thread ID' },
main_thread_proc_no => { hdr => 'Main Thread Proc', num => 1, label => 'Main thread process number' },
main_thread_state => { hdr => 'Main Thread State', num => 0, label => 'Main thread state' },
@@ -1596,9 +1715,12 @@ my %columns = (
master_ssl_cipher => { hdr => 'Master SSL Cipher', num => 0, label => 'Master SSL Cipher' },
master_ssl_key => { hdr => 'Master SSL Key', num => 0, label => 'Master SSL Key' },
master_user => { hdr => 'Master User', num => 0, label => 'Master username' },
+ master_uuid => { hdr => 'Master UUID', num => 0, label => 'Master UUID', },
max_txn => { hdr => 'MaxTxnTime', num => 1, label => 'MaxTxn' },
+ max_query_time => { hdr => 'MaxSQL', num => 1, label => 'Longest running SQL' },
merged_recs => { hdr => 'Merged Recs', num => 1, label => 'Merged records' },
merges => { hdr => 'Merges', num => 1, label => 'Merges' },
+ miss_rate => { hdr => 'Miss', num => 1, label => 'InnoDB buffer pool miss rate' },
mutex_os_waits => { hdr => 'Waits', num => 1, label => 'Mutex OS Waits' },
mutex_spin_rounds => { hdr => 'Rounds', num => 1, label => 'Mutex Spin Rounds' },
mutex_spin_waits => { hdr => 'Spins', num => 1, label => 'Mutex Spin Waits' },
@@ -1619,6 +1741,7 @@ my %columns = (
num_txns => { hdr => 'Txns', num => 1, label => 'Number of transactions' },
num_updates => { hdr => 'Upd', num => 1, label => 'Number of updates' },
num_updates_sec => { hdr => 'Upd/Sec', num => 1, label => 'Number of updates' },
+ 'open' => { hdr => 'Tbls', num => 1, label => 'Number of open tables' },
os_file_reads => { hdr => 'OS Reads', num => 1, label => 'OS file reads' },
os_file_writes => { hdr => 'OS Writes', num => 1, label => 'OS file writes' },
os_fsyncs => { hdr => 'OS fsyncs', num => 1, label => 'OS fsyncs' },
@@ -1653,6 +1776,7 @@ my %columns = (
port => { hdr => 'Port', num => 1, label => 'Client port number', },
possible_keys => { hdr => 'Poss. Keys', num => 0, label => 'Possible keys' },
proc_no => { hdr => 'Proc', num => 1, label => 'Process number' },
+ q_detail => { hdr => 'Se/In/Up/De%', num => 0, label => 'Detailed Query', },
q_cache_hit => { hdr => 'QCacheHit', num => 1, label => 'Query cache hit ratio', },
qps => { hdr => 'QPS', num => 1, label => 'How many queries/sec', },
queries_in_queue => { hdr => 'Queries Queued', num => 1, label => 'Queries in queue' },
@@ -1676,14 +1800,23 @@ my %columns = (
replicate_wild_ignore_table => { hdr => 'Wild Ignore Table', num => 0, label => 'Replicate-wild-ignore-table setting' },
request_type => { hdr => 'Type', num => 0, label => 'Type of lock the thread waits for' },
reservation_count => { hdr => 'ResCnt', num => 1, label => 'Reservation Count' },
+ retrieved_gtid_set => { hdr => 'Retrieved GTID Set', num => 0, label => 'Retrieved GTID Set', },
row_locks => { hdr => 'RLocks', num => 1, label => 'Number of row locks' },
+ rows_changed => { hdr => 'Changed', num => 1, label => 'Number of rows changed' },
+ rows_changed_x_indexes => { hdr => 'Chg X Idx', num => 1, label => 'Number of rows changed X indexes' },
+ rows_read => { hdr => 'Reads', num => 1, label => 'Number of rows read' },
+ rows_read_from_indexes => { hdr => 'Reads Via Idx', num => 1, label => 'Number of rows read from indexes' },
+ run => { hdr => 'Run', num => 1, label => 'Threads_running' },
rw_excl_os_waits => { hdr => 'RW Waits', num => 1, label => 'R/W Excl. OS Waits' },
rw_excl_spins => { hdr => 'RW Spins', num => 1, label => 'R/W Excl. Spins' },
rw_shared_os_waits => { hdr => 'Sh Waits', num => 1, label => 'R/W Shared OS Waits' },
rw_shared_spins => { hdr => 'Sh Spins', num => 1, label => 'R/W Shared Spins' },
+ spark_qps => { hdr => 'QPS', num => 0, label => 'QPS Sparkline' },
+ spark_run => { hdr => 'Run', num => 0, label => 'Threads_running Sparkline' },
scan_type => { hdr => 'Type', num => 0, label => 'Scan type in chosen' },
seg_size => { hdr => 'Seg. Size', num => 1, label => 'Segment size' },
select_type => { hdr => 'Select Type', num => 0, label => 'Type of select used' },
+ server_uuid => { hdr => 'Server UUID', num => 0, label => 'Server UUID', },
signal_count => { hdr => 'Signals', num => 1, label => 'Signal Count' },
size => { hdr => 'Size', num => 1, label => 'Size of the tablespace' },
skip_counter => { hdr => 'Skip Counter', num => 1, label => 'Skip counter' },
@@ -1691,7 +1824,9 @@ my %columns = (
slave_io_running => { hdr => 'Slave-IO', num => 0, label => 'Whether the slave I/O thread is running' },
slave_io_state => { hdr => 'Slave IO State', num => 0, label => 'Slave I/O thread state' },
slave_open_temp_tables => { hdr => 'Temp', num => 1, label => 'Slave open temp tables' },
+ slave_running => { hdr => 'Repl', num => 0, label => 'Slave running' },
slave_sql_running => { hdr => 'Slave-SQL', num => 0, label => 'Whether the slave SQL thread is running' },
+ sort_time => { hdr => 'SortTimeLag', num => 1, label => 'Time slave lags master sort' },
slow => { hdr => 'Slow', num => 1, label => 'How many slow queries', },
space_id => { hdr => 'Space', num => 1, label => 'Tablespace ID' },
special => { hdr => 'Special', num => 0, label => 'Special/Other info' },
@@ -1718,6 +1853,7 @@ my %columns = (
undo_for => { hdr => 'Undo', num => 0, label => 'Undo for' },
until_condition => { hdr => 'Until Condition', num => 0, label => 'Slave until condition' },
until_log_file => { hdr => 'Until Log File', num => 0, label => 'Slave until log file' },
+ uptime => { hdr => 'Uptime', num => 1, label => 'Uptime' },
until_log_pos => { hdr => 'Until Log Pos', num => 1, label => 'Slave until log position' },
used_cells => { hdr => 'Cells Used', num => 1, label => 'Number of cells used' },
used_bufs => { hdr => 'Used Bufs', num => 1, label => 'Number of buffer pool pages used' },
@@ -1731,6 +1867,14 @@ my %columns = (
waited_at_line => { hdr => 'Line', num => 1, label => 'Line at which thread waits' },
waiters_flag => { hdr => 'Waiters', num => 1, label => 'Waiters Flag' },
waiting => { hdr => 'Waiting', num => 1, label => 'Whether lock is being waited for' },
+ waiting_thread => { hdr => 'WThread', num => 1, label => 'Waiting thread' },
+ waiting_query => { hdr => 'Waiting Query', num => 0, label => 'Waiting query' },
+ waiting_rows_modified => { hdr => 'WRowsMod', num => 1, label => 'Waiting number rows modified' },
+ waiting_age => { hdr => 'WAge', num => 1, label => 'Waiting age' },
+ waiting_wait_secs => { hdr => 'WWait', num => 1, label => 'Waiting wait time' },
+ waiting_user => { hdr => 'WUser', num => 0, label => 'Waiting user' },
+ waiting_host => { hdr => 'WHost', num => 0, label => 'Waiting host' },
+ waiting_db => { hdr => 'WDB', num => 0, label => 'Waiting database' },
when => { hdr => 'When', num => 0, label => 'Time scale' },
writer_lock_mode => { hdr => 'Wrtr Lck Mode', num => 0, label => 'Writer lock mode' },
writer_thread => { hdr => 'Wrtr Thread', num => 1, label => 'Writer thread ID' },
@@ -1763,8 +1907,7 @@ my %filters = ();
my %builtin_filters = (
hide_self => {
text => <<' END',
- return ( !$set->{info} || $set->{info} ne 'SHOW FULL PROCESSLIST' )
- && ( !$set->{query_text} || $set->{query_text} !~ m/INNODB STATUS$/ );
+ return ( ($set->{info} || '') !~ m#/\*innotop\*/# );
END
note => 'Removes the innotop processes from the list',
tbls => [qw(innodb_transactions processlist)],
@@ -1773,18 +1916,33 @@ my %builtin_filters = (
text => <<' END',
return ( !defined($set->{txn_status}) || $set->{txn_status} ne 'not started' )
&& ( !defined($set->{cmd}) || $set->{cmd} !~ m/Sleep|Binlog Dump/ )
+ && ( !defined($set->{state}) || $set->{state} !~ m/^handlersocket/ )
&& ( !defined($set->{info}) || $set->{info} =~ m/\S/ );
END
note => 'Removes processes which are not doing anything',
tbls => [qw(innodb_transactions processlist)],
},
+ hide_connect => {
+ text => <<' END',
+ return ( !defined($set->{cmd}) || $set->{cmd} !~ m/Connect/ );
+ END
+ note => 'Removes the slave processes from the list',
+ tbls => [qw(processlist)],
+ },
hide_slave_io => {
text => <<' END',
- return !$set->{state} || $set->{state} !~ m/^(?:Waiting for master|Has read all relay)/;
+ return !$set->{state} || $set->{state} !~ m/^(?:Waiting for master|read all relay)/;
END
note => 'Removes slave I/O threads from the list',
tbls => [qw(processlist slave_io_status)],
},
+ hide_event => {
+ text => <<' END',
+ return (($set->{state} || '') !~ m/^Daemon/) || (($set->{info} || '') !~ m/\S/);
+ END
+ note => 'Removes idle event threads from the list',
+ tbls => [qw(processlist)],
+ },
table_is_open => {
text => <<' END',
return $set->{num_times_open} + $set->{is_name_locked};
@@ -2038,11 +2196,13 @@ my %agg_funcs = (
my %trans_funcs = (
shorten => \&shorten,
secs_to_time => \&secs_to_time,
+ distill => \&distill,
no_ctrl_char => \&no_ctrl_char,
percent => \&percent,
commify => \&commify,
dulint_to_int => \&dulint_to_int,
set_precision => \&set_precision,
+ fuzzy_time => \&fuzzy_time,
);
# Table definitions {{{3
@@ -2123,6 +2283,7 @@ my %tbl_meta = (
capt => 'Command Summary',
cust => {},
cols => {
+ cxn => { src => 'cxn' },
name => { src => 'name' },
total => { src => 'total' },
value => { src => 'value', agg => 'sum'},
@@ -2131,7 +2292,7 @@ my %tbl_meta = (
last_value => { src => 'last_value', agg => 'sum'},
last_pct => { src => 'last_value/last_total', trans => [qw(percent)] },
},
- visible => [qw(name value pct last_value last_pct)],
+ visible => [qw(cxn name value pct last_value last_pct)],
filters => [qw()],
sort_cols => '-value',
sort_dir => '1',
@@ -2281,6 +2442,49 @@ my %tbl_meta = (
group_by => [],
aggregate => 0,
},
+ index_statistics => {
+ capt => 'Data from INDEX_STATISTICS',
+ cust => {},
+ cols => {
+ cxn => { src => 'cxn', minw => 6, maxw => 10 },
+ db => { src => 'table_schema' },
+ tbl => { src => 'table_name' },
+ index => { src => 'index_name' },
+ rows_read => { src => 'rows_read', agg => 'sum' },
+ },
+ visible => [ qw(cxn db tbl index rows_read) ],
+ filters => [ ],
+ sort_cols => 'rows_read',
+ sort_dir => '-1',
+ innodb => '',
+ colors => [],
+ hide_caption => 1,
+ group_by => [qw(cxn db tbl)],
+ aggregate => 0,
+ },
+ index_table_statistics => {
+ capt => 'Data from {TABLE,INDEX}_STATISTICS',
+ cust => {},
+ cols => {
+ cxn => { src => 'cxn', minw => 6, maxw => 10 },
+ db => { src => 'table_schema' },
+ tbl => { src => 'table_name' },
+ index => { src => 'index_name' },
+ rows_read => { src => 'rows_read' },
+ rows_read_from_indexes => { src => 'rows_read_from_indexes' },
+ rows_changed => { src => 'rows_changed' },
+ rows_changed_x_indexes => { src => 'rows_changed_x_indexes' },
+ },
+ visible => [ qw(cxn db tbl rows_read rows_read_from_indexes rows_changed rows_changed_x_indexes) ],
+ filters => [ ],
+ sort_cols => 'rows_read',
+ sort_dir => '-1',
+ innodb => '',
+ colors => [],
+ hide_caption => 1,
+ group_by => [qw(cxn db tbl)],
+ aggregate => 0,
+ },
insert_buffers => {
capt => 'Insert Buffers',
cust => {},
@@ -2301,6 +2505,43 @@ my %tbl_meta = (
group_by => [],
aggregate => 0,
},
+ innodb_blocked_blocker => {
+ capt => 'InnoDB Blocked/Blocking',
+ cust => {},
+ cols => {
+ cxn => { src => 'cxn' },
+ waiting_thread => { src => 'waiting_thread' },
+ waiting_query => { src => 'waiting_query', trans => [qw(distill)] },
+ waiting_rows_modified => { src => 'waiting_rows_modified' },
+ waiting_age => { src => 'waiting_age', trans => [qw(fuzzy_time)] },
+ waiting_wait_secs => { src => 'waiting_wait_secs', trans => [qw(fuzzy_time)] },
+ waiting_user => { src => 'waiting_user' },
+ waiting_host => { src => 'waiting_host' },
+ waiting_db => { src => 'waiting_db' },
+ blocking_thread => { src => 'blocking_thread' },
+ blocking_query => { src => 'blocking_query', trans => [qw(distill)] },
+ blocking_rows_modified => { src => 'blocking_rows_modified' },
+ blocking_age => { src => 'blocking_age', trans => [qw(fuzzy_time)] },
+ blocking_wait_secs => { src => 'blocking_wait_secs', trans => [qw(fuzzy_time)] },
+ blocking_user => { src => 'blocking_user' },
+ blocking_host => { src => 'blocking_host' },
+ blocking_db => { src => 'blocking_db' },
+ blocking_status => { src => 'blocking_status' },
+ lock_info => { src => 'lock_info' },
+ },
+ visible => [ qw(cxn waiting_thread waiting_query waiting_wait_secs
+ blocking_thread blocking_rows_modified blocking_age blocking_wait_secs
+ blocking_status blocking_query)],
+ filters => [],
+ sort_cols => 'cxn -waiting_wait_secs',
+ sort_dir => '1',
+ innodb => 'tx',
+ colors => [
+ ],
+ group_by => [],
+ aggregate => 0,
+ hide_caption => 1,
+ },
innodb_locks => {
capt => 'InnoDB Locks',
cust => {},
@@ -2429,19 +2670,22 @@ my %tbl_meta = (
capt => 'Master Status',
cust => {},
cols => {
- cxn => { src => 'cxn' },
+ cxn => { src => $exprs{chcxn_2_cxn}, hdr => 'CXN' },
binlog_do_db => { src => 'binlog_do_db' },
binlog_ignore_db => { src => 'binlog_ignore_db' },
master_file => { src => 'file' },
master_pos => { src => 'position' },
binlog_cache_overflow => { src => '(Binlog_cache_disk_use||0)/(Binlog_cache_use||1)', trans => [ qw(percent) ] },
+ executed_gtid_set => { src => '(executed_gtid_set||"N/A")' },
+ server_uuid => { src => '(server_uuid||"N/A")' },
+ channel_name => { src => $exprs{chcxn_2_ch}, hdr => 'Channel'},
},
- visible => [ qw(cxn master_file master_pos binlog_cache_overflow)],
+ visible => [ qw(cxn channel_name master_file master_pos binlog_cache_overflow executed_gtid_set server_uuid)],
filters => [ qw(cxn_is_master) ],
sort_cols => 'cxn',
sort_dir => '1',
innodb => '',
- group_by => [],
+ group_by => [qw(channel_name)],
aggregate => 0,
},
pending_io => {
@@ -2512,7 +2756,7 @@ my %tbl_meta = (
cxn => { src => 'cxn', minw => 6, maxw => 10 },
mysql_thread_id => { src => 'id', minw => 6, maxw => 0 },
user => { src => 'user', minw => 5, maxw => 8 },
- hostname => { src => $exprs{Host}, minw => 13, maxw => 8, },
+ hostname => { src => $exprs{Host}, minw => 7, maxw => 15, },
port => { src => $exprs{Port}, minw => 0, maxw => 0, },
host_and_port => { src => 'host', minw => 0, maxw => 0 },
db => { src => 'db', minw => 6, maxw => 12 },
@@ -2523,7 +2767,7 @@ my %tbl_meta = (
cnt => { src => 'id', minw => 0, maxw => 0 },
},
visible => [ qw(cxn cmd cnt mysql_thread_id state user hostname db time info)],
- filters => [ qw(hide_self hide_inactive hide_slave_io) ],
+ filters => [ qw(hide_self hide_inactive hide_slave_io hide_event hide_connect) ],
sort_cols => '-time cxn hostname mysql_thread_id',
sort_dir => '1',
innodb => '',
@@ -2556,14 +2800,16 @@ my %tbl_meta = (
questions => { src => 'Questions' },
qps => { src => 'Questions/Uptime_hires', dec => 1, trans => [qw(shorten)] },
load => { src => $exprs{ServerLoad}, dec => 1, trans => [qw(shorten)] },
+ connections => { src => $exprs{Connection}, dec => 1, trans => [qw(shorten)] },
slow => { src => 'Slow_queries', dec => 1, trans => [qw(shorten)] },
q_cache_hit => { src => $exprs{QcacheHitRatio}, dec => 1, trans => [qw(percent)] },
key_buffer_hit => { src => '1-(Key_reads/(Key_read_requests||1))', dec => 1, trans => [qw(percent)] },
bps_in => { src => 'Bytes_received/Uptime_hires', dec => 1, trans => [qw(shorten)] },
bps_out => { src => 'Bytes_sent/Uptime_hires', dec => 1, trans => [qw(shorten)] },
when => { src => 'when' },
+ q_detail => { src => $exprs{QueryDetail} },
},
- visible => [ qw(cxn when load qps slow q_cache_hit key_buffer_hit bps_in bps_out)],
+ visible => [ qw(cxn when load connections qps slow q_detail q_cache_hit key_buffer_hit bps_in bps_out)],
filters => [],
sort_cols => 'when cxn',
sort_dir => '1',
@@ -2646,9 +2892,10 @@ my %tbl_meta = (
capt => 'Slave I/O Status',
cust => {},
cols => {
- cxn => { src => 'cxn' },
+ cxn => { src => $exprs{chcxn_2_cxn}, hdr => 'CXN' },
connect_retry => { src => 'connect_retry' },
master_host => { src => 'master_host', hdr => 'Master'},
+ master_uuid => { src => '(master_uuid||"N/A")' },
master_log_file => { src => 'master_log_file', hdr => 'File' },
master_port => { src => 'master_port' },
master_ssl_allowed => { src => 'master_ssl_allowed' },
@@ -2662,27 +2909,29 @@ my %tbl_meta = (
relay_log_size => { src => 'relay_log_space', trans => [qw(shorten)] },
slave_io_running => { src => 'slave_io_running', hdr => 'On?' },
slave_io_state => { src => 'slave_io_state', hdr => 'State' },
+ channel_name => { src => $exprs{chcxn_2_ch}, hdr => 'Channel'},
},
- visible => [ qw(cxn master_host slave_io_running master_log_file relay_log_size read_master_log_pos slave_io_state)],
+ visible => [ qw(cxn channel_name master_host master_uuid slave_io_running master_log_file relay_log_size read_master_log_pos slave_io_state)],
filters => [ qw( cxn_is_slave ) ],
- sort_cols => 'slave_io_running cxn',
+ sort_cols => 'slave_io_running channel_name cxn',
colors => [
{ col => 'slave_io_running', op => 'ne', arg => 'Yes', color => 'black on_red' },
],
sort_dir => '1',
innodb => '',
- group_by => [],
+ group_by => [qw(channel_name)],
aggregate => 0,
},
slave_sql_status => {
capt => 'Slave SQL Status',
cust => {},
cols => {
- cxn => { src => 'cxn' },
+ cxn => { src => $exprs{chcxn_2_cxn}, hdr => 'CXN' },
exec_master_log_pos => { src => 'exec_master_log_pos', hdr => 'Master Pos' },
last_errno => { src => 'last_errno' },
last_error => { src => 'last_error' },
master_host => { src => 'master_host', hdr => 'Master' },
+ master_uuid => { src => '(master_uuid||"N/A")' },
relay_log_file => { src => 'relay_log_file' },
relay_log_pos => { src => 'relay_log_pos' },
relay_log_size => { src => 'relay_log_space', trans => [qw(shorten)] },
@@ -2695,6 +2944,7 @@ my %tbl_meta = (
replicate_wild_ignore_table => { src => 'replicate_wild_ignore_table' },
skip_counter => { src => 'skip_counter' },
slave_sql_running => { src => 'slave_sql_running', hdr => 'On?' },
+ sort_time => { src => 'int(seconds_behind_master/60)' },
until_condition => { src => 'until_condition' },
until_log_file => { src => 'until_log_file' },
until_log_pos => { src => 'until_log_pos' },
@@ -2702,10 +2952,13 @@ my %tbl_meta = (
bytes_behind_master => { src => 'master_log_file && master_log_file eq relay_master_log_file ? read_master_log_pos - exec_master_log_pos : 0', trans => [qw(shorten)] },
slave_catchup_rate => { src => $exprs{SlaveCatchupRate}, trans => [ qw(set_precision) ] },
slave_open_temp_tables => { src => 'Slave_open_temp_tables' },
+ retrieved_gtid_set => { src => '(retrieved_gtid_set||"N/A")' },
+ executed_gtid_set => { src => '(executed_gtid_set||"N/A")' },
+ channel_name => { src => $exprs{chcxn_2_ch}, hdr => 'Channel'},
},
- visible => [ qw(cxn master_host slave_sql_running time_behind_master slave_catchup_rate slave_open_temp_tables relay_log_pos last_error)],
+ visible => [ qw(cxn channel_name master_host master_uuid slave_sql_running time_behind_master slave_catchup_rate slave_open_temp_tables relay_log_pos last_error retrieved_gtid_set executed_gtid_set)],
filters => [ qw( cxn_is_slave ) ],
- sort_cols => 'slave_sql_running cxn',
+ sort_cols => 'slave_sql_running -sort_time channel_name cxn',
sort_dir => '1',
innodb => '',
colors => [
@@ -2714,6 +2967,27 @@ my %tbl_meta = (
{ col => 'time_behind_master', op => '>', arg => 60, color => 'yellow' },
{ col => 'time_behind_master', op => '==', arg => 0, color => 'white' },
],
+ group_by => [qw(channel_name)],
+ aggregate => 0,
+ },
+ table_statistics => {
+ capt => 'Data from TABLE_STATISTICS',
+ cust => {},
+ cols => {
+ cxn => { src => 'cxn', minw => 6, maxw => 10 },
+ db => { src => 'table_schema' },
+ tbl => { src => 'table_name' },
+ rows_read => { src => 'rows_read' },
+ rows_changed => { src => 'rows_changed' },
+ rows_changed_x_indexes => { src => 'rows_changed_x_indexes' },
+ },
+ visible => [ qw(cxn db tbl rows_read rows_changed rows_changed_x_indexes) ],
+ filters => [ ],
+ sort_cols => 'rows_read',
+ sort_dir => '-1',
+ innodb => '',
+ colors => [],
+ hide_caption => 1,
group_by => [],
aggregate => 0,
},
@@ -2789,6 +3063,43 @@ my %tbl_meta = (
group_by => [],
aggregate => 0,
},
+ health_dashboard => {
+ capt => 'Health Dashboard',
+ hide_caption => 1,
+ cust => {},
+ cols => {
+ cxn => { src => 'cxn' },
+ uptime => { src => 'Uptime', trans => [qw(fuzzy_time)] },
+ qps => { src => 'Questions/Uptime_hires', dec => 1, trans => [qw(shorten)] },
+ spark_qps => { src => 'SPARK_qps' },
+ run => { src => 'User_threads_running' },
+ spark_run => { src => 'SPARK_run' },
+ max_query_time => { src => 'Max_query_time', trans => [qw(fuzzy_time)] },
+ connections => { src => 'Threads_connected' },
+ miss_rate => { src => 'Innodb_buffer_pool_reads/Uptime_hires', trans => [qw(set_precision)] },
+ locked_count => { src => 'Locked_count' },
+ 'open' => { src => 'Open_tables' },
+ slave_running => { src => 'Slave_ok . " " . (Slaves || "")' },
+ time_behind_master => { src => 'seconds_behind_master', hdr => 'ReplLag' , trans => [qw(fuzzy_time)] },
+ longest_sql => { src => 'Longest_sql', trans => [qw(distill)] },
+ },
+ visible => [qw(
+ cxn uptime max_query_time time_behind_master qps connections run
+ miss_rate locked_count open slave_running longest_sql
+ )],
+ filters => [],
+ sort_cols => 'cxn',
+ sort_dir => '1',
+ innodb => '',
+ colors => [
+ { col => 'slave_running', op => '=~', arg => 'No', color => 'black on_red' },
+ { col => 'max_query_time', op => '>', arg => 30 * 60, color => 'red' },
+ { col => 'max_query_time', op => '>', arg => 600, color => 'yellow' },
+ { col => 'time_behind_master', op => '>', arg => 3600, color => 'cyan' },
+ ],
+ group_by => [],
+ aggregate => 0,
+ },
);
# Initialize %tbl_meta from %columns and do some checks.
@@ -2849,6 +3160,35 @@ foreach my $table_name ( keys %tbl_meta ) {
# Operating modes {{{3
# ###########################################################################
my %modes = (
+ A => {
+ hdr => 'Dashboard',
+ cust => {},
+ note => 'Shows health/status dashboard',
+ action_for => {
+ k => {
+ action => sub { kill_query('CONNECTION') },
+ label => "Kill a query's connection",
+ },
+ x => {
+ action => sub { kill_query('QUERY') },
+ label => "Kill a query",
+ },
+ r => {
+ action => sub { reverse_sort('health_dashboard'); },
+ label => 'Reverse sort order',
+ },
+ s => {
+ action => sub { choose_sort_cols('health_dashboard'); },
+ label => "Choose sort column",
+ },
+ },
+ display_sub => \&display_A,
+ connections => [],
+ server_group => '',
+ one_connection => 0,
+ tables => [qw(health_dashboard)],
+ visible_tables => [qw(health_dashboard)],
+ },
B => {
hdr => 'InnoDB Buffers',
cust => {},
@@ -2933,6 +3273,23 @@ my %modes = (
tables => [qw(io_threads pending_io file_io_misc log_statistics)],
visible_tables => [qw(io_threads pending_io file_io_misc log_statistics)],
},
+ K => {
+ hdr => 'InnoDB Lock Waits',
+ cust => {},
+ note => 'Shows blocked and blocking transactions',
+ action_for => {
+ k => {
+ action => sub { kill_query('CONNECTION') },
+ label => "Kill a query's connection",
+ },
+ },
+ display_sub => \&display_K,
+ connections => [],
+ server_group => '',
+ one_connection => 0,
+ tables => [qw(innodb_blocked_blocker)],
+ visible_tables => [qw(innodb_blocked_blocker)],
+ },
L => {
hdr => 'Locks',
cust => {},
@@ -3004,6 +3361,35 @@ my %modes = (
tables => [qw(open_tables)],
visible_tables => [qw(open_tables)],
},
+ U => {
+ hdr => 'User Statistics',
+ cust => {},
+ note => 'Displays Percona/MariaDB enhancements such as table statistics',
+ action_for => {
+ i => {
+ action => sub { set_visible_table('index_statistics') },
+ label => 'Switch to INDEX_STATISTICS',
+ },
+ s => {
+ action => sub { $clear_screen_sub->(); send_cmd_to_servers('SET @@global.userstat_running := 1 - @@global.userstat_running', 1, undef, []); },
+ label => "Change the display's sort column",
+ },
+ t => {
+ action => sub { set_visible_table('table_statistics') },
+ label => 'Switch to TABLE_STATISTICS',
+ },
+ x => {
+ action => sub { set_visible_table('index_table_statistics') },
+ label => 'Switch to {INDEX,TABLE}_STATISTICS',
+ },
+ },
+ display_sub => \&display_P,
+ connections => [],
+ server_group => '',
+ one_connection => 0,
+ tables => [qw(table_statistics index_statistics index_table_statistics)],
+ visible_tables => [qw(index_table_statistics)],
+ },
Q => {
hdr => 'Query List',
cust => {},
@@ -3045,6 +3431,10 @@ my %modes = (
action => sub { choose_sort_cols('processlist'); },
label => "Change the display's sort column",
},
+ t => {
+ action => sub { toggle_filter('processlist', 'hide_connect') },
+ label => 'Toggle slave processes',
+ },
x => {
action => sub { kill_query('QUERY') },
label => "Kill a query",
@@ -3239,6 +3629,10 @@ my %action_for = (
label => 'Toggle aggregation',
},
# TODO: can these be auto-generated from %modes?
+ A => {
+ action => sub { switch_mode('A') },
+ label => '',
+ },
B => {
action => sub { switch_mode('B') },
label => '',
@@ -3259,6 +3653,10 @@ my %action_for = (
action => sub { switch_mode('I') },
label => '',
},
+ K => {
+ action => sub { switch_mode('K') },
+ label => '',
+ },
L => {
action => sub { switch_mode('L') },
label => '',
@@ -3287,6 +3685,10 @@ my %action_for = (
action => sub { switch_mode('T') },
label => '',
},
+ U => {
+ action => sub { switch_mode('U') },
+ label => '',
+ },
d => {
action => sub { get_config_interactive('interval') },
label => 'Change refresh interval',
@@ -3554,6 +3956,7 @@ my %tbl_editor_action = (
dec => 0,
agg => 0,
aggonly => 0,
+ agghide => 0,
};
$tbl_meta{$tbl}->{visible} = [ unique(@{$tbl_meta{$tbl}->{visible}}, $col) ];
@@ -3754,6 +4157,8 @@ my $nonfatal_errs = join('|',
'Cannot call SHOW INNODB STATUS',
'Access denied',
'AutoCommit',
+ 'Lost connection to MySQL server',
+ 'Too many connections',
);
if ( !$opts{n} ) {
@@ -3766,8 +4171,10 @@ if ( !$opts{n} ) {
# keyed on clock tick.
my %vars;
my %info_gotten = (); # Which things have been retrieved for the current clock tick.
+my %show_variables; # Stores SHOW VARIABLES for each cxn so we don't re-fetch.
-# Stores info on currently displayed queries: cxn, connection ID, query text.
+# Stores info on currently displayed queries: cxn, connection ID, query text,
+# user, and host.
my @current_queries;
my $lines_printed = 0;
@@ -3935,7 +4342,7 @@ my %config = (
conf => 'ALL',
},
mode => {
- val => "Q",
+ val => "A",
note => "Which mode to start in",
cmdline => 1,
},
@@ -3961,6 +4368,17 @@ my %config = (
note => 'Which set of variables to display in S (Variables & Status) mode',
conf => [ qw(S) ],
},
+ timeformat => {
+ val => '%Y-%m-%dT%H:%M:%S',
+ pat => qr//,
+ note => 'The strftime() timestamp format to write in -n mode',
+ },
+ spark => {
+ val => 10,
+ note => 'How long to make status variable sparklines',
+ conf => 'ALL',
+ pat => $int_regex,
+ },
);
# ###########################################################################
@@ -4076,57 +4494,196 @@ my %pluggable_vars = (
# given DB connection. Returns a $sth.
# ###########################################################################
my %stmt_maker_for = (
+ INDEX_STATISTICS => sub {
+ my ( $dbh ) = @_;
+ # Detect whether there's a Percona Server with INFORMATION_SCHEMA.INDEX_STATISTICS
+ # and if not, just select nothing.
+ my $sth;
+ eval { # This can fail if the table doesn't exist, INFORMATION_SCHEMA doesn't exist, etc.
+ my $cols = $dbh->selectall_arrayref(q{SHOW /*innotop*/ COLUMNS FROM INFORMATION_SCHEMA.INDEX_STATISTICS});
+ if ( @$cols ) {
+ $sth = $dbh->prepare(q{SELECT /*innotop*/ * FROM INFORMATION_SCHEMA.INDEX_STATISTICS});
+ }
+ };
+ $sth ||= $dbh->prepare(q{SELECT /*innotop*/ '' FROM DUAL WHERE 1 = 0});
+ return $sth;
+ },
+ INDEX_TABLE_STATISTICS => sub {
+ my ( $dbh ) = @_;
+ # Detect whether there's a Percona Server with INFORMATION_SCHEMA.INDEX_STATISTICS
+ # and if not, just select nothing.
+ my $sth;
+ eval { # This can fail if the table doesn't exist, INFORMATION_SCHEMA doesn't exist, etc.
+ my $cols = $dbh->selectall_arrayref(q{SHOW /*innotop*/ COLUMNS FROM INFORMATION_SCHEMA.INDEX_STATISTICS});
+ if ( @$cols ) {
+ $sth = $dbh->prepare(q{SELECT /*innotop*/ L.TABLE_SCHEMA, L.TABLE_NAME, }
+ . q{SUM(L.ROWS_READ) AS ROWS_READ, SUM(R.ROWS_READ) AS ROWS_READ_FROM_INDEXES, }
+ . q{SUM(L.ROWS_CHANGED) AS ROWS_CHANGED, }
+ . q{SUM(L.ROWS_CHANGED_X_INDEXES) AS ROWS_CHANGED_X_INDEXES }
+ . q{FROM INFORMATION_SCHEMA.TABLE_STATISTICS AS L LEFT JOIN INFORMATION_SCHEMA.INDEX_STATISTICS AS R }
+ . q{USING(TABLE_SCHEMA, TABLE_NAME) GROUP BY L.TABLE_SCHEMA, L.TABLE_NAME});
+ }
+ };
+ $sth ||= $dbh->prepare(q{SELECT /*innotop*/ '' FROM DUAL WHERE 1 = 0});
+ return $sth;
+ },
+ INNODB_BLOCKED_BLOCKER => sub {
+ my ( $dbh ) = @_;
+ # Detect whether the server supports the I_S tables and if not, just select nothing.
+ my $sth;
+ eval { # This can fail if the table doesn't exist, INFORMATION_SCHEMA doesn't exist, etc.
+ my $cols = $dbh->selectall_arrayref(q{SHOW /*innotop*/ COLUMNS FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS});
+ if ( @$cols ) {
+ if ($dbh->{mysql_serverinfo} =~ /^5.1/) {
+ $sth = $dbh->prepare(q{
+ SELECT /*innotop*/
+ r.trx_mysql_thread_id AS waiting_thread,
+ r.trx_query AS waiting_query,
+ "n/a" AS waiting_rows_modified,
+ TIMESTAMPDIFF(SECOND, r.trx_started, NOW()) AS waiting_age,
+ TIMESTAMPDIFF(SECOND, r.trx_wait_started, NOW()) AS waiting_wait_secs,
+ rp.user AS waiting_user,
+ rp.host AS waiting_host,
+ rp.db AS waiting_db,
+ b.trx_mysql_thread_id AS blocking_thread,
+ b.trx_query AS blocking_query,
+ "n/a" AS blocking_rows_modified,
+ TIMESTAMPDIFF(SECOND, b.trx_started, NOW()) AS blocking_age,
+ TIMESTAMPDIFF(SECOND, b.trx_wait_started, NOW()) AS blocking_wait_secs,
+ bp.user AS blocking_user,
+ bp.host AS blocking_host,
+ bp.db AS blocking_db,
+ CONCAT(bp.command, IF(bp.command = 'Sleep', CONCAT(' ', bp.time), '')) AS blocking_status,
+ CONCAT(lock_mode, ' ', lock_type, ' ', lock_table, '(', lock_index, ')') AS lock_info
+ FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS w
+ JOIN INFORMATION_SCHEMA.INNODB_TRX b ON b.trx_id = w.blocking_trx_id
+ JOIN INFORMATION_SCHEMA.INNODB_TRX r ON r.trx_id = w.requesting_trx_id
+ JOIN INFORMATION_SCHEMA.INNODB_LOCKS l ON l.lock_id = w.requested_lock_id
+ LEFT JOIN INFORMATION_SCHEMA.PROCESSLIST bp ON bp.id = b.trx_mysql_thread_id
+ LEFT JOIN INFORMATION_SCHEMA.PROCESSLIST rp ON rp.id = r.trx_mysql_thread_id
+ });
+ } else {
+ $sth = $dbh->prepare(q{
+ SELECT /*innotop*/
+ r.trx_mysql_thread_id AS waiting_thread,
+ r.trx_query AS waiting_query,
+ r.trx_rows_modified AS waiting_rows_modified,
+ TIMESTAMPDIFF(SECOND, r.trx_started, NOW()) AS waiting_age,
+ TIMESTAMPDIFF(SECOND, r.trx_wait_started, NOW()) AS waiting_wait_secs,
+ rp.user AS waiting_user,
+ rp.host AS waiting_host,
+ rp.db AS waiting_db,
+ b.trx_mysql_thread_id AS blocking_thread,
+ b.trx_query AS blocking_query,
+ b.trx_rows_modified AS blocking_rows_modified,
+ TIMESTAMPDIFF(SECOND, b.trx_started, NOW()) AS blocking_age,
+ TIMESTAMPDIFF(SECOND, b.trx_wait_started, NOW()) AS blocking_wait_secs,
+ bp.user AS blocking_user,
+ bp.host AS blocking_host,
+ bp.db AS blocking_db,
+ CONCAT(bp.command, IF(bp.command = 'Sleep', CONCAT(' ', bp.time), '')) AS blocking_status,
+ CONCAT(lock_mode, ' ', lock_type, ' ', lock_table, '(', lock_index, ')') AS lock_info
+ FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS w
+ JOIN INFORMATION_SCHEMA.INNODB_TRX b ON b.trx_id = w.blocking_trx_id
+ JOIN INFORMATION_SCHEMA.INNODB_TRX r ON r.trx_id = w.requesting_trx_id
+ JOIN INFORMATION_SCHEMA.INNODB_LOCKS l ON l.lock_id = w.requested_lock_id
+ LEFT JOIN INFORMATION_SCHEMA.PROCESSLIST bp ON bp.id = b.trx_mysql_thread_id
+ LEFT JOIN INFORMATION_SCHEMA.PROCESSLIST rp ON rp.id = r.trx_mysql_thread_id
+ });
+ }
+ }
+ };
+ $sth ||= $dbh->prepare(q{SELECT /*innotop*/ '' FROM DUAL WHERE 1 = 0});
+ return $sth;
+ },
INNODB_STATUS => sub {
my ( $dbh ) = @_;
return $dbh->prepare(version_ge( $dbh, '5.0.0' )
- ? 'SHOW ENGINE INNODB STATUS'
- : 'SHOW INNODB STATUS');
+ ? 'SHOW /*innotop*/ ENGINE INNODB STATUS'
+ : 'SHOW /*innotop*/ INNODB STATUS');
},
SHOW_VARIABLES => sub {
my ( $dbh ) = @_;
return $dbh->prepare($config{global}->{val} && version_ge( $dbh, '4.0.3' )
- ? 'SHOW GLOBAL VARIABLES'
- : 'SHOW VARIABLES');
+ ? 'SHOW /*innotop*/ GLOBAL VARIABLES'
+ : 'SHOW /*innotop*/ VARIABLES');
},
SHOW_STATUS => sub {
my ( $dbh ) = @_;
return $dbh->prepare($config{global}->{val} && version_ge( $dbh, '5.0.2' )
- ? 'SHOW GLOBAL STATUS'
- : 'SHOW STATUS');
+ ? 'SHOW /*innotop*/ GLOBAL STATUS'
+ : 'SHOW /*innotop*/ STATUS');
},
KILL_QUERY => sub {
my ( $dbh ) = @_;
return $dbh->prepare(version_ge( $dbh, '5.0.0' )
- ? 'KILL QUERY ?'
- : 'KILL ?');
+ ? 'KILL /*innotop*/ QUERY ?'
+ : 'KILL /*innotop*/ ?');
},
SHOW_MASTER_LOGS => sub {
my ( $dbh ) = @_;
- return $dbh->prepare('SHOW MASTER LOGS');
+ return $dbh->prepare('SHOW /*innotop*/ MASTER LOGS');
},
SHOW_MASTER_STATUS => sub {
my ( $dbh ) = @_;
- return $dbh->prepare('SHOW MASTER STATUS');
+ return $dbh->prepare('SHOW /*innotop*/ MASTER STATUS');
},
SHOW_SLAVE_STATUS => sub {
my ( $dbh ) = @_;
- return $dbh->prepare('SHOW SLAVE STATUS');
+ return $dbh->prepare('SHOW /*innotop*/ SLAVE STATUS');
+ },
+ GET_CHANNELS => sub {
+ my ( $dbh ) = @_;
+ return $dbh->prepare(version_ge( $dbh, '5.7.0' )
+ ? 'select CHANNEL_NAME from performance_schema.replication_applier_status where CHANNEL_NAME regexp "^[a-zA-Z].*";'
+ : 'select "no_channels"');
},
KILL_CONNECTION => sub {
my ( $dbh ) = @_;
return $dbh->prepare(version_ge( $dbh, '5.0.0' )
- ? 'KILL CONNECTION ?'
- : 'KILL ?');
+ ? 'KILL /*innotop*/ CONNECTION ?'
+ : 'KILL /*innotop*/ ?');
},
OPEN_TABLES => sub {
my ( $dbh ) = @_;
return version_ge($dbh, '4.0.0')
- ? $dbh->prepare('SHOW OPEN TABLES')
+ ? $dbh->prepare('SHOW /*innotop*/ OPEN TABLES')
: undef;
},
PROCESSLIST => sub {
my ( $dbh ) = @_;
- return $dbh->prepare('SHOW FULL PROCESSLIST');
+ # In newer versions of the server, use INFORMATION_SCHEMA table if it exists,
+ # and use the TIME_MS column (in Percona Server) if that exists.
+ my $sth;
+ eval { # This can fail if the table doesn't exist, INFORMATION_SCHEMA doesn't exist, etc.
+ my $cols = $dbh->selectall_arrayref(q{SHOW /*innotop*/ COLUMNS FROM INFORMATION_SCHEMA.PROCESSLIST LIKE 'TIME_MS'});
+ if ( @$cols ) { # The TIME_MS colum exists
+ $sth = $dbh->prepare(q{SELECT /*innotop*/ ID, USER, HOST, DB, COMMAND, CASE WHEN TIME_MS/1000 > 365*86400 THEN TIME ELSE TIME_MS/1000 END AS TIME, STATE, INFO FROM INFORMATION_SCHEMA.PROCESSLIST});
+ }
+ };
+ $sth ||= $dbh->prepare('SHOW /*innotop*/ FULL PROCESSLIST');
+ return $sth;
+ },
+ PROCESSLIST_NO_IS => sub {
+ my ( $dbh ) = @_;
+ # We do not use INFORMATION_SCHEMA table because it doesn't show slave
+ # SQL statements. http://bugs.mysql.com/66401
+ my $sth = $dbh->prepare('SHOW /*innotop*/ FULL PROCESSLIST');
+ return $sth;
+ },
+ TABLE_STATISTICS => sub {
+ my ( $dbh ) = @_;
+ # Detect whether there's a Percona Server with INFORMATION_SCHEMA.TABLE_STATISTICS
+ # and if not, just select nothing.
+ my $sth;
+ eval { # This can fail if the table doesn't exist, INFORMATION_SCHEMA doesn't exist, etc.
+ my $cols = $dbh->selectall_arrayref(q{SHOW /*innotop*/ COLUMNS FROM INFORMATION_SCHEMA.TABLE_STATISTICS});
+ if ( @$cols ) {
+ $sth = $dbh->prepare(q{SELECT /*innotop*/ * FROM INFORMATION_SCHEMA.TABLE_STATISTICS});
+ }
+ };
+ $sth ||= $dbh->prepare(q{SELECT /*innotop*/ '' FROM DUAL WHERE 1 = 0});
+ return $sth;
},
);
@@ -4137,137 +4694,144 @@ my %plugins = (
# ###########################################################################
# Run the program {{{1
# ###########################################################################
-
-# This config variable is only useful for MS Windows because its terminal
-# can't tell how tall it is.
-if ( !$windows ) {
- delete $config{max_height};
-}
-
-# Try to lower my priority.
-eval { setpriority(0, 0, getpriority(0, 0) + 10); };
-
-# Print stuff to the screen immediately, don't wait for a newline.
-$OUTPUT_AUTOFLUSH = 1;
-
-# Clear the screen and load the configuration.
-$clear_screen_sub->();
-load_config();
-
-# Override config variables with command-line options
-my %cmdline =
- map { $_->{c} => $opts{$_->{k}} }
- grep { exists $_->{c} && exists $opts{$_->{k}} }
- @opt_spec;
-
-foreach my $name (keys %cmdline) {
- next if not defined $cmdline{$name};
- my $val = $cmdline{$name};
- if ( exists($config{$name}) and (!$config{$name}->{pat} or $val =~ m/$config{$name}->{pat}/ )) {
- $config{$name}->{val} = $val;
+sub main {
+ # This config variable is only useful for MS Windows because its terminal
+ # can't tell how tall it is.
+ if ( !$windows ) {
+ delete $config{max_height};
}
-}
-
-post_process_tbl_meta();
-
-# Make sure no changes are written to config file in non-interactive mode.
-if ( $opts{n} ) {
- $config{readonly}->{val} = 1;
-}
-
-eval {
-
- # Open the file for InnoDB status
- if ( @ARGV ) {
- my $filename = shift @ARGV;
- open $file, "<", $filename
- or die "Cannot open '$filename': $OS_ERROR";
+
+ # Try to lower my priority.
+ eval { setpriority(0, 0, getpriority(0, 0) + 10); };
+
+ # Print stuff to the screen immediately, don't wait for a newline.
+ $OUTPUT_AUTOFLUSH = 1;
+
+ # Clear the screen and load the configuration.
+ $clear_screen_sub->();
+ load_config();
+
+ # Override config variables with command-line options
+ my %cmdline =
+ map { $_->{c} => $opts{$_->{k}} }
+ grep { exists $_->{c} && exists $opts{$_->{k}} }
+ @opt_spec;
+
+ foreach my $name (keys %cmdline) {
+ next if not defined $cmdline{$name};
+ my $val = $cmdline{$name};
+ if ( exists($config{$name}) and (!$config{$name}->{pat} or $val =~ m/$config{$name}->{pat}/ )) {
+ $config{$name}->{val} = $val;
+ }
}
-
- # In certain modes we might have to collect data for two cycles
- # before printing anything out, so we need to bump up the count one.
- if ( $opts{n} && $opts{count} && $config{status_inc}->{val}
- && $config{mode}->{val} =~ m/[S]/ )
- {
- $opts{count}++;
+
+ post_process_tbl_meta();
+
+ # Make sure no changes are written to config file in non-interactive mode.
+ if ( $opts{n} ) {
+ $config{readonly}->{val} = 1;
}
-
- while (++$clock) {
-
- my $mode = $config{mode}->{val} || 'Q';
- if ( !$modes{$mode} ) {
- die "Mode '$mode' doesn't exist; try one of these:\n"
- . join("\n", map { " $_ $modes{$_}->{hdr}" } sort keys %modes)
- . "\n";
- }
-
- if ( !$opts{n} ) {
- @last_term_size = @this_term_size;
- @this_term_size = Term::ReadKey::GetTerminalSize(\*STDOUT);
- if ( $windows ) {
- $this_term_size[0]--;
- $this_term_size[1]
- = min($this_term_size[1], $config{max_height}->{val});
- }
- die("Can't read terminal size") unless @this_term_size;
+
+ eval {
+
+ # Open the file for InnoDB status
+ if ( @ARGV ) {
+ my $filename = shift @ARGV;
+ open $file, "<", $filename
+ or die "Cannot open '$filename': $OS_ERROR";
}
-
- # If there's no connection to a database server, we need to fix that...
- if ( !%connections ) {
- print "You have not defined any database connections.\n\n";
- add_new_dsn();
+
+ # In certain modes we might have to collect data for two cycles
+ # before printing anything out, so we need to bump up the count one.
+ if ( $opts{n} && $opts{count} && $config{status_inc}->{val}
+ && $config{mode}->{val} =~ m/[S]/ )
+ {
+ $opts{count}++;
}
+
+ while (++$clock) {
+
+ my $mode = $config{mode}->{val} || 'Q';
+ if ( !$modes{$mode} ) {
+ die "Mode '$mode' doesn't exist; try one of these:\n"
+ . join("\n", map { " $_ $modes{$_}->{hdr}" } sort keys %modes)
+ . "\n";
+ }
+
+ if ( !$opts{n} ) {
+ @last_term_size = @this_term_size;
+ @this_term_size = Term::ReadKey::GetTerminalSize(\*STDOUT);
+ if ( $windows ) {
+ $this_term_size[0]--;
+ $this_term_size[1]
+ = min($this_term_size[1], $config{max_height}->{val});
+ }
+ die("Can't read terminal size") unless @this_term_size;
+ }
+
+ # If there's no connection to a database server, we need to fix that...
+ if ( !%connections ) {
+ print "You have not defined any database connections.\n\n";
+ add_new_dsn();
+ }
+
+ # See whether there are any connections defined for this mode. If there's only one
+ # connection total, assume the user wants to just use innotop for a single server
+ # and don't ask which server to connect to. Also, if we're monitoring from a file,
+ # we just use the first connection.
+ if ( !get_connections() ) {
+ if ( $file || 1 == scalar keys %connections ) {
+ $modes{$config{mode}->{val}}->{connections} = [ keys %connections ];
+ }
+ else {
+ choose_connections();
+ }
+ }
+
+ # Term::ReadLine might have re-set $OUTPUT_AUTOFLUSH.
+ $OUTPUT_AUTOFLUSH = 1;
+
+ # Prune old data
+ my $sets = $config{num_status_sets}->{val};
+ foreach my $store ( values %vars ) {
+ delete @{$store}{ grep { $_ < $clock - $sets } keys %$store };
+ }
+ %info_gotten = ();
+
+ # Call the subroutine to display this mode.
+ $modes{$mode}->{display_sub}->();
+
+ # It may be time to quit now.
+ if ( $opts{count} && $clock >= $opts{count} ) {
+ finish();
+ }
- # See whether there are any connections defined for this mode. If there's only one
- # connection total, assume the user wants to just use innotop for a single server
- # and don't ask which server to connect to. Also, if we're monitoring from a file,
- # we just use the first connection.
- if ( !get_connections() ) {
- if ( $file || 1 == scalar keys %connections ) {
- $modes{$config{mode}->{val}}->{connections} = [ keys %connections ];
+ # RECON: Try to reconnect failed connections, while the user sees no lag.
+ foreach my $cxn ( grep { $dbhs{$_}->{failed} } keys %dbhs ) {
+ eval { connect_to_db($cxn); }; # Ignore errors entirely here.
+ }
+
+ # Wait for a bit.
+ if ( $opts{n} ) {
+ sleep($config{interval}->{val});
}
else {
- choose_connections();
+ ReadMode('cbreak');
+ $char = ReadKey($config{interval}->{val});
+ ReadMode('normal');
}
+
+ # Handle whatever action the key indicates.
+ do_key_action();
+
}
-
- # Term::ReadLine might have re-set $OUTPUT_AUTOFLUSH.
- $OUTPUT_AUTOFLUSH = 1;
-
- # Prune old data
- my $sets = $config{num_status_sets}->{val};
- foreach my $store ( values %vars ) {
- delete @{$store}{ grep { $_ < $clock - $sets } keys %$store };
- }
- %info_gotten = ();
-
- # Call the subroutine to display this mode.
- $modes{$mode}->{display_sub}->();
-
- # It may be time to quit now.
- if ( $opts{count} && $clock >= $opts{count} ) {
- finish();
- }
-
- # Wait for a bit.
- if ( $opts{n} ) {
- sleep($config{interval}->{val});
- }
- else {
- ReadMode('cbreak');
- $char = ReadKey($config{interval}->{val});
- ReadMode('normal');
- }
-
- # Handle whatever action the key indicates.
- do_key_action();
-
+ };
+ if ( $EVAL_ERROR ) {
+ core_dump( $EVAL_ERROR );
}
-};
-if ( $EVAL_ERROR ) {
- core_dump( $EVAL_ERROR );
+ finish();
}
-finish();
+main() unless caller(); # make me testable!
# Subroutines {{{1
# Mode functions{{{2
@@ -4355,6 +4919,29 @@ sub prompt_noecho {
return $response;
}
+# noecho_password {{{3
+# read password for command line parameters with noecho
+sub noecho_password {
+ my $prompt = shift @_;
+ local $OUTPUT_AUTOFLUSH = 1;
+ my $response;
+ eval {
+ if ( $windows ) {
+ require Win32::Console::ANSI;
+ }
+ require Term::ANSIColor;
+ import Term::ANSIColor qw(colored);
+ $response = prompt_noecho($prompt);
+ print "\n" or die
+ "Cannot print: $OS_ERROR";
+ };
+
+ if ( $EVAL_ERROR ) {
+ die "Cannot read respose; is Term::ReadKey installed? $EVAL_ERROR";
+ }
+ return $response;
+}
+
# do_key_action {{{3
# Depending on whether a key was read, do something. Keys have certain
# actions defined in lookup tables. Each mode may have its own lookup table,
@@ -4364,11 +4951,9 @@ sub do_key_action {
if ( defined $char ) {
my $mode = $config{mode}->{val};
my $action
- = defined($modes{$mode}->{action_for}->{$char})
- ? $modes{$mode}->{action_for}->{$char}->{action}
- : defined($action_for{$char})
- ? $action_for{$char}->{action}
- : sub{};
+ = defined($modes{$mode}->{action_for}->{$char}) ? $modes{$mode}->{action_for}->{$char}->{action}
+ : defined($action_for{$char}) ? $action_for{$char}->{action}
+ : sub{};
$action->();
}
}
@@ -4420,7 +5005,13 @@ sub kill_query {
'Select a thread to kill the ' . $q_or_c,
);
return unless $info;
- return unless pause("Kill $info->{id}?") =~ m/y/i;
+ my $distill = distill($info->{query} || '');
+ $distill = " running '$distill'" if $distill;
+ return unless pause("Kill $info->{id} ("
+ . ($info->{user} || '')
+ . '@'
+ . ($info->{host} || '')
+ . ")$distill ? ") =~ m/y/i;
eval {
do_stmt($info->{cxn}, $q_or_c eq 'QUERY' ? 'KILL_QUERY' : 'KILL_CONNECTION', $info->{id} );
@@ -4491,6 +5082,10 @@ sub deadlock_thread {
eval {
my $dbh = get_new_db_connection($cxn, 1);
+
+ # disable binary logging for this session
+ $dbh->do("set SQL_LOG_BIN=0");
+
my @stmts = (
"set transaction isolation level serializable",
(version_ge($dbh, '4.0.11') ? "start transaction" : 'begin'),
@@ -4591,10 +5186,49 @@ sub start_S_mode {
switch_mode('S');
}
+# display_A {{{3
+sub display_A {
+ my @display_lines;
+ my @cxns = get_connections();
+ get_processlist_stats(@cxns);
+ get_status_info(@cxns);
+ get_master_slave_status(@cxns);
+ my @visible = get_visible_tables();
+ my %wanted = map { $_ => 1 } @visible;
+ my @health_dashboard;
+ my %rows_for = (
+ health_dashboard => \@health_dashboard,
+ );
+
+ foreach my $cxn ( @cxns ) {
+ # Get the status variables
+ my $set = $vars{$cxn}->{$clock};
+ my $pre = $vars{$cxn}->{$clock-1} || $set;
+ my $hash = extract_values($set, $set, $pre, 'health_dashboard');
+ # Make QPS and Miss show now, not overall.
+ if ( exists $vars{$cxn}->{$clock - 1} ) {
+ my $inc = inc(0, $cxn);
+ my $hash2 = extract_values($inc, $set, $pre, 'health_dashboard');
+ map { $hash->{$_} = $hash2->{$_} } qw(qps miss_rate);
+ }
+ push @health_dashboard, $hash;
+ }
+
+ my $first_table = 0;
+ foreach my $tbl ( @visible ) {
+ push @display_lines, '', set_to_tbl($rows_for{$tbl}, $tbl);
+ push @display_lines, get_cxn_errors(@cxns)
+ if ( $config{debug}->{val} || !$first_table++ );
+ }
+
+ draw_screen(\@display_lines);
+}
+
# display_B {{{3
sub display_B {
my @display_lines;
my @cxns = get_connections();
+ get_status_info(@cxns);
get_innodb_status(\@cxns);
my @buffer_pool;
@@ -4705,6 +5339,7 @@ sub display_C {
sub display_D {
my @display_lines;
my @cxns = get_connections();
+ get_status_info(@cxns);
get_innodb_status(\@cxns);
my @deadlock_transactions;
@@ -4769,12 +5404,13 @@ sub display_D {
sub display_F {
my @display_lines;
my ( $cxn ) = get_connections();
+ get_status_info($cxn);
get_innodb_status([$cxn]);
my $innodb_status = $vars{$cxn}->{$clock};
if ( $innodb_status->{IB_fk_timestring} ) {
- push @display_lines, 'Reason: ' . $innodb_status->{IB_fk_reason};
+ push @display_lines, 'Reason: ' . ($innodb_status->{IB_fk_reason} || 'unknown');
# Display FK errors caused by invalid DML.
if ( $innodb_status->{IB_fk_txn} ) {
@@ -4803,6 +5439,7 @@ sub display_F {
sub display_I {
my @display_lines;
my @cxns = get_connections();
+ get_status_info(@cxns);
get_innodb_status(\@cxns);
my @io_threads;
@@ -4859,10 +5496,52 @@ sub display_I {
draw_screen(\@display_lines);
}
+# display_K {{{3
+sub display_K {
+ my @display_lines;
+ my @cxns = get_connections();
+
+ my %rows_for = (
+ innodb_blocked_blocker => [],
+ );
+
+ my @visible = get_visible_tables();
+ my %wanted = map { $_ => 1 } @visible;
+
+ # Get info on locks
+ if ( $wanted{innodb_blocked_blocker} ) {
+ my @rows = get_innodb_blocked_blocker(@cxns);
+ push @{$rows_for{innodb_blocked_blocker}}, map { extract_values($_, $_, $_, 'innodb_blocked_blocker') } @rows;
+ }
+
+ my $first_table = 0;
+ foreach my $tbl ( @visible ) {
+ push @display_lines, '', set_to_tbl($rows_for{$tbl}, $tbl);
+ push @display_lines, get_cxn_errors(@cxns)
+ if ( $config{debug}->{val} || !$first_table++ );
+ }
+
+ # Save queries in global variable for analysis. The rows in %rows_for have been
+ # filtered, etc as a side effect of set_to_tbl(), so they are the same as the rows
+ # that get pushed to the screen.
+ @current_queries = map {
+ my %hash;
+ @hash{ qw(cxn id user host db query time) }
+ = @{$_}{ qw(cxn blocking_thread blocking_user blocking_host blocking_db blocking_query blocking_age) };
+ # time is in fuzzy-time format; convert into something ascii-sortable.
+ $hash{time} = sprintf('%012s', fuzzy_to_secs($hash{time}));
+ $hash{host} =~ s/:.*$// if $hash{host};
+ \%hash;
+ } @{$rows_for{innodb_blocked_blocker}};
+
+ draw_screen(\@display_lines);
+}
+
# display_L {{{3
sub display_L {
my @display_lines;
my @cxns = get_connections();
+ get_status_info(@cxns);
get_innodb_status(\@cxns);
my @innodb_locks;
@@ -4882,8 +5561,8 @@ sub display_L {
my $cur_txns = $set->{IB_tx_transactions};
my $pre_txns = $pre->{IB_tx_transactions} || $cur_txns;
- my %cur_txns = map { $_->{mysql_thread_id} => $_ } @$cur_txns;
- my %pre_txns = map { $_->{mysql_thread_id} => $_ } @$pre_txns;
+ my %cur_txns = map { $_->{mysql_thread_id} => $_ } grep { defined $_->{mysql_thread_id} } @$cur_txns;
+ my %pre_txns = map { $_->{mysql_thread_id} => $_ } grep { defined $_->{mysql_thread_id} } @$pre_txns;
foreach my $txn ( @$cur_txns ) {
foreach my $lock ( @{$txn->{locks}} ) {
my %hash = map { $_ => $txn->{$_} } qw(txn_id mysql_thread_id lock_wait_time active_secs);
@@ -4925,18 +5604,46 @@ sub display_M {
my %wanted = map { $_ => 1 } @visible;
foreach my $cxn ( @cxns ) {
- my $set = $config{status_inc}->{val} ? inc(0, $cxn) : $vars{$cxn}->{$clock};
- my $pre = $vars{$cxn}->{$clock - 1} || $set;
- if ( $wanted{slave_sql_status} ) {
- push @slave_sql_status, extract_values($set, $set, $pre, 'slave_sql_status');
- }
- if ( $wanted{slave_io_status} ) {
- push @slave_io_status, extract_values($set, $set, $pre, 'slave_io_status');
- }
- if ( $wanted{master_status} ) {
- push @master_status, extract_values($set, $set, $pre, 'master_status');
- }
- }
+ my $linecount=0;
+ my $sth = do_stmt($cxn, 'GET_CHANNELS');
+ my ( $channel );
+ $sth->execute();
+ $sth->bind_columns( \$channel );
+ while ( $sth->fetch() ) {
+ $linecount=$linecount+1;
+ if ( length $channel < 1 ) {
+ $channel = 'no_channels';
+ }
+ my $chcxn = $channel . '=' . $cxn;
+ get_slave_status($cxn,$channel);
+ my $set = $config{status_inc}->{val} ? inc(0, $chcxn) : $vars{$chcxn}->{$clock};
+ my $pre = $vars{$chcxn}->{$clock - 1} || $set;
+ if ( $wanted{slave_sql_status} ) {
+ push @slave_sql_status, extract_values($set, $set, $pre, 'slave_sql_status');
+ }
+ if ( $wanted{slave_io_status} ) {
+ push @slave_io_status, extract_values($set, $set, $pre, 'slave_io_status');
+ }
+ }
+ if ( $linecount < 1 ) {
+ $channel = 'no_channels';
+ my $chcxn = $channel . '=' . $cxn;
+ get_slave_status($cxn,$channel);
+ my $set = $config{status_inc}->{val} ? inc(0, $chcxn) : $vars{$chcxn}->{$clock};
+ my $pre = $vars{$chcxn}->{$clock - 1} || $set;
+ if ( $wanted{slave_sql_status} ) {
+ push @slave_sql_status, extract_values($set, $set, $pre, 'slave_sql_status');
+ }
+ if ( $wanted{slave_io_status} ) {
+ push @slave_io_status, extract_values($set, $set, $pre, 'slave_io_status');
+ }
+ }
+ my $set = $config{status_inc}->{val} ? inc(0, $cxn) : $vars{$cxn}->{$clock};
+ my $pre = $vars{$cxn}->{$clock - 1} || $set;
+ if ( $wanted{master_status} ) {
+ push @master_status, extract_values($set, $set, $pre, 'master_status');
+ }
+ }
my $first_table = 0;
foreach my $tbl ( @visible ) {
@@ -4958,6 +5665,49 @@ sub display_O {
draw_screen(\@display_lines);
}
+# display_P {{{3
+sub display_P {
+ my @display_lines;
+
+ my @table_statistics;
+ my @index_statistics;
+ my @index_table_statistics;
+ my %rows_for = (
+ table_statistics => \@table_statistics,
+ index_statistics => \@index_statistics,
+ index_table_statistics => \@index_table_statistics,
+ );
+
+ my @visible = $opts{n} ? 'index_table_statistics' : get_visible_tables();
+ my %wanted = map { $_ => 1 } @visible;
+
+ # Get the data
+ my @cxns = get_connections();
+
+ if ( $wanted{table_statistics} ) {
+ my @rows = get_table_statistics(@cxns);
+ push @table_statistics, map { extract_values($_, $_, $_, 'table_statistics') } @rows;
+ }
+ elsif ( $wanted{index_statistics} ) {
+ my @rows = get_index_statistics(@cxns);
+ push @index_statistics, map { extract_values($_, $_, $_, 'index_statistics') } @rows;
+ }
+ elsif ( $wanted{index_table_statistics} ) {
+ my @rows = get_index_table_statistics(@cxns);
+ push @index_table_statistics, map { extract_values($_, $_, $_, 'index_table_statistics') } @rows;
+ }
+
+ my $first_table = 0;
+ foreach my $tbl ( @visible ) {
+ next unless $wanted{$tbl};
+ push @display_lines, '', set_to_tbl($rows_for{$tbl}, $tbl);
+ push @display_lines, get_cxn_errors(@cxns)
+ if ( $config{debug}->{val} || !$first_table++ );
+ }
+
+ draw_screen(\@display_lines);
+}
+
# display_Q {{{3
sub display_Q {
my @display_lines;
@@ -5015,7 +5765,11 @@ sub display_Q {
# that get pushed to the screen.
@current_queries = map {
my %hash;
- @hash{ qw(cxn id db query secs) } = @{$_}{ qw(cxn mysql_thread_id db info secs) };
+ @hash{ qw(cxn id db query time user host) }
+ = @{$_}{ qw(cxn mysql_thread_id db info time user hostname) };
+ # time is in seconds-to-time format; convert into something
+ # ascii-sortable.
+ $hash{time} = sprintf('%012s', $hash{time} =~ m/^([^.]*)/);
\%hash;
} @{$rows_for{processlist}};
@@ -5026,6 +5780,7 @@ sub display_Q {
sub display_R {
my @display_lines;
my @cxns = get_connections();
+ get_status_info(@cxns);
get_innodb_status(\@cxns);
my @row_operations;
@@ -5098,6 +5853,8 @@ sub display_T {
my @cxns = get_connections();
+ get_status_info(@cxns);
+
# If the header is to be shown, buffer pool data is required.
get_innodb_status( \@cxns, [ $wanted{t_header} ? qw(bp) : () ] );
@@ -5115,8 +5872,8 @@ sub display_T {
if ( $wanted{innodb_transactions} ) {
my $cur_txns = $set->{IB_tx_transactions};
my $pre_txns = $pre->{IB_tx_transactions} || $cur_txns;
- my %cur_txns = map { $_->{mysql_thread_id} => $_ } @$cur_txns;
- my %pre_txns = map { $_->{mysql_thread_id} => $_ } @$pre_txns;
+ my %cur_txns = map { $_->{mysql_thread_id} => $_ } grep { defined $_->{mysql_thread_id} } @$cur_txns;
+ my %pre_txns = map { $_->{mysql_thread_id} => $_ } grep { defined $_->{mysql_thread_id} } @$pre_txns;
foreach my $thd_id ( sort keys %cur_txns ) {
my $cur_txn = $cur_txns{$thd_id};
my $pre_txn = $pre_txns{$thd_id} || $cur_txn;
@@ -5140,7 +5897,8 @@ sub display_T {
# that get pushed to the screen.
@current_queries = map {
my %hash;
- @hash{ qw(cxn id db query secs) } = @{$_}{ qw(cxn mysql_thread_id db query_text active_secs) };
+ @hash{ qw(cxn id db query time user host) }
+ = @{$_}{ qw(cxn mysql_thread_id db query_text active_secs user hostname) };
\%hash;
} @{$rows_for{innodb_transactions}};
@@ -5468,7 +6226,10 @@ sub display_help {
}
# Magic keys
- my @all_magic = map { sprintf('%4s', $action_for{$_}->{key} || $_) . " $keys{$_}" } @magic;
+ my @all_magic = map {
+ my $k = $action_for{$_} ? ($action_for{$_}->{key} || $_) : $_;
+ sprintf('%4s %s', $k, $keys{$_});
+ } @magic;
@col1 = splice(@all_magic, 0, ceil(@all_magic/2));
$max1 = max(map {length($_)} @col1);
push @display_lines, '', 'Other:';
@@ -5781,14 +6542,32 @@ sub set_to_tbl {
my ( $rows, $tbl ) = @_;
my $meta = $tbl_meta{$tbl} or die "No such table $tbl in tbl_meta";
- # don't show cxn if there's only one connection being displayed
- my @visible;
- if (scalar @{$modes{$config{mode}->{val}}->{connections}} == 1) {
+ # don't show / hide cxn if there's only one connection being displayed
+ my (@visible, @group_by);
+ my $num_cxn = scalar get_connections();
+ if ($num_cxn <= 1) {
map { push @visible, $_ if $_ !~ /^cxn$/ } @{$meta->{visible}};
- delete $$rows[0]{cxn} if defined $$rows[0]{cxn};
+ $meta->{visible} = \@visible;
+ map { push @group_by, $_ if $_ !~ /^cxn$/ } @{$meta->{group_by}};
+ $meta->{group_by} = \@group_by;
}
+ # if cxn is not visible and there is now more than one connection,
+ # make cxn visible again. assume it's not in group_by if it's not
+ # visible
else {
- @visible = @{$meta->{visible}};
+ my $has_cxn = 0;
+ foreach my $column (@{$meta->{visible}}) {
+ if ($column eq "cxn") {
+ $has_cxn = 1;
+ last;
+ }
+ }
+ if (not $has_cxn) {
+ map { push @visible, $_ if $_ !~ /^cxn$/ } @{$meta->{visible}};
+ $meta->{visible} = \@visible;
+ map { push @group_by, $_ if $_ !~ /^cxn$/ } @{$meta->{group_by}};
+ $meta->{group_by} = \@group_by;
+ }
}
if ( !$meta->{pivot} ) {
@@ -5943,14 +6722,15 @@ sub set_to_tbl {
# If the table isn't pivoted, just show all columns that are supposed to
# be shown; but eliminate aggonly columns if the table isn't aggregated.
my $aggregated = $meta->{aggregate};
- $fmt_cols = [ grep { $aggregated || !$meta->{cols}->{$_}->{aggonly} } @visible ];
+ $fmt_cols = [ grep { $aggregated || !$meta->{cols}->{$_}->{aggonly} } @{$meta->{visible}} ];
$fmt_meta = { map { $_ => $meta->{cols}->{$_} } @$fmt_cols };
# If the table is aggregated, re-order the group_by columns to the left of
- # the display.
+ # the display, and suppress 'agghide' columns.
if ( $aggregated ) {
my %is_group = map { $_ => 1 } @{$meta->{group_by}};
$fmt_cols = [ @{$meta->{group_by}}, grep { !$is_group{$_} } @$fmt_cols ];
+ $fmt_cols = [ grep { !$meta->{cols}->{$_}->{agghide} } @$fmt_cols ];
}
}
@@ -5991,6 +6771,7 @@ sub commify {
# Trim to desired precision.
sub set_precision {
my ( $num, $precision ) = @_;
+ $num = 0 unless defined $num;
$precision = $config{num_digits}->{val} if !defined $precision;
sprintf("%.${precision}f", $num);
}
@@ -6005,6 +6786,23 @@ sub percent {
. ($config{show_percent}->{val} ? '%' : '');
}
+# sparkify {{{3
+# Find the range (min to max) and divide it up. Each value then gets put into
+# a bucket and represented by one of these characters: _.-=^
+sub sparkify {
+ my @vals = @_;
+ my @chars = qw(_ . - = ^);
+ my $min = min(@vals);
+ my $max = max(@vals);
+ my $range = ($max - $min) / 4;
+ return "_" x scalar(@vals) if !$min || !$max || $max == $min || !$range;
+ my $result = "";
+ foreach my $v ( @vals ) {
+ $result .= $chars[ int(($v - $min) / $range) ];
+ }
+ return $result;
+}
+
# shorten {{{3
sub shorten {
my ( $num, $opts ) = @_;
@@ -6023,12 +6821,9 @@ sub shorten {
$num /= 1_024;
++$n;
}
- return sprintf(
- $num =~ m/\./ || $n || $force
- ? "%.${num_digits}f%s"
- : '%d',
- $num, ($pad,'k','M','G', 'T')[$n]);
-
+ return $num =~ m/\./ || $n || $force
+ ? sprintf("%.${num_digits}f%s", $num, ($pad,'k','M','G','T')[$n])
+ : $num;
}
# Utility functions {{{2
@@ -6214,12 +7009,23 @@ sub draw_screen {
if $prefs->{clear} || !$modes{$config{mode}->{val}}->{no_clear_screen};
if ( $opts{n} || $prefs->{raw} ) {
my $num_lines = 0;
+ my $ts = $opts{t} ? POSIX::strftime($config{timeformat}->{val}, localtime) : '';
+ if ( $opts{t} ) {
+ if ( $opts{t} == 1 ) {
+ print "\n$ts\n\n";
+ $ts = ""; # Prevent it from being written on every line.
+ $num_lines++;
+ }
+ else {
+ $ts .= " ";
+ }
+ }
print join("\n",
map {
$num_lines++;
ref $_
- ? colored($_->[0], $_->[1])
- : $_;
+ ? colored($ts . $_->[0], $_->[1])
+ : $ts . $_;
}
grep { !$opts{n} || $_ } # Suppress empty lines
@$display_lines);
@@ -6240,11 +7046,169 @@ sub draw_screen {
}
}
+# fuzzy_time {{{3
+sub fuzzy_time {
+ my ( $secs ) = @_;
+ return '' unless $secs;
+ return sprintf('%.2f', $secs) if $secs =~ m/^.\./;
+ $secs =~ s/\..*$//;
+ return $secs < 180 ? "${secs}s"
+ : $secs < 3600 ? sprintf("%dm", $secs / 60)
+ : $secs < 3600 * 3 ? sprintf("%dh%dm", $secs / 3600, ($secs % 3600) / 60)
+ : $secs < 86400 ? sprintf("%dh", $secs / 3600)
+ : $secs < 86400* 3 ? sprintf("%dd%dh", $secs / 86400, ($secs % 86400) / 3600)
+ : sprintf("%dd", $secs / 86400);
+}
+
+sub fuzzy_to_secs {
+ my ($t) = @_;
+ return 0 unless $t;
+ my ($num, $suffix) = $t =~ m/(\d+)([a-z])?$/;
+ return $num unless $suffix;
+ return $suffix eq 's' ? $num # Seconds
+ : $suffix eq 'm' ? $num * 60 # Minutes
+ : $suffix eq 'h' ? $num * 3600 # Hours
+ : $num * 86400; # Days
+}
+
+# distill {{{3
+sub distill {
+ my ( $query ) = @_;
+ return "" unless $query;
+ my $orig_query = $query;
+
+ $query =~ m/\A\s*call\s+(\S+)\(/i && return "CALL $1";
+ $query =~ m/\A\s*use\s+/ && return "USE";
+ $query =~ m/\A\s*UNLOCK TABLES/i && return "UNLOCK";
+ $query =~ m/\A\s*xa\s+(\S+)/i && return "XA_$1";
+
+ # Strip out comments
+ my $olc_re = qr/(?:--|#)[^'"\r\n]*(?=[\r\n]|\Z)/; # One-line comments
+ my $mlc_re = qr#/\*[^!].*?\*/#sm; # But not /*!version */
+ my $vlc_re = qr#/\*.*?[0-9+].*?\*/#sm; # For SHOW + /*!version */
+ my $vlc_rf = qr#^(SHOW).*?/\*![0-9+].*?\*/#sm; # Variation for SHOW
+ $query =~ s/$olc_re//go;
+ $query =~ s/$mlc_re//go;
+ if ( $query =~ m/$vlc_rf/i ) { # contains show + version
+ $query =~ s/$vlc_re//go;
+ }
+
+ # Handle SHOW queries
+ if ( $query =~ m/\A\s*SHOW\s+/i ) {
+ $query = uc $query;
+ $query =~ s/\s+(?:GLOBAL|SESSION|FULL|STORAGE|ENGINE)\b/ /g;
+ $query =~ s/\s+COUNT[^)]+\)//g;
+ $query =~ s/\s+(?:FOR|FROM|LIKE|WHERE|LIMIT|IN)\b.+//ms;
+ $query =~ s/\A(SHOW(?:\s+\S+){1,2}).*\Z/$1/s;
+ $query =~ s/\s+/ /g;
+ }
+
+ # Find verbs and tables.
+ my ($verbs, $table);
+
+ # Handle DDL operations (dds)
+ my $tbl_ident = qr/(?:`[^`]+`|\w+)(?:\.(?:`[^`]+`|\w+))?/;
+ my $tbl_regex = qr{
+ \b(?:FROM|JOIN|(? 1 ) {
+ # False-positive verbs after SELECT
+ my $union = grep { $_ eq 'UNION' } @verbs;
+ @verbs = $union ? qw(SELECT UNION) : qw(SELECT);
+ }
+
+ my %seen;
+ $verbs = join(q{ }, grep { !$seen{$_}++ } @verbs);
+ }
+
+ if ( $verbs && $verbs =~ m/^SHOW/ ) {
+ my %alias_for = qw(
+ SCHEMA DATABASE
+ KEYS INDEX
+ INDEXES INDEX
+ );
+ map { $verbs =~ s/$_/$alias_for{$_}/ } keys %alias_for;
+ $query = $verbs;
+ }
+ else {
+ my @tables;
+ $query =~ s/ (?:LOW_PRIORITY|IGNORE|STRAIGHT_JOIN)//ig;
+ if ( $query =~ /^\s*LOCK\s+TABLES/i ) {
+ $query =~ s/^(\s*LOCK\s+TABLES\s+)//i;
+ $query =~ s/\s+(?:READ|WRITE|LOCAL)+\s*//gi;
+ $query = "FROM $query";
+ }
+ $query =~ s/\\["']//g; # quoted strings
+ $query =~ s/".*?"/?/sg; # quoted strings
+ $query =~ s/'.*?'/?/sg; # quoted strings
+
+ foreach my $tbls ( $query =~ m/$tbl_regex/gio ) {
+ next if $tbls =~ m/\ASELECT\b/i;
+ foreach my $tbl ( split(',', $tbls) ) {
+ $tbl =~ s/\s*($tbl_ident)(\s+.*)?/$1/gio;
+ if ( $tbl !~ m/[a-zA-Z]/ ) {
+ # Skip suspicious table name
+ next;
+ }
+ push @tables, $tbl;
+ }
+ }
+
+ # If we have a bunch of tables like db1.tbl1 db1.tbl2, convert to
+ # db1.tbl1 -.tbl2 etc. Also remove repeated tables, and strip `quotes`.
+ $query = $verbs;
+ my $prev = '';
+ foreach my $t ( @tables, $table ) {
+ next unless $t;
+ $t =~ s/`//g;
+ next if $t eq $prev;
+ my ($prefix, undef) = split(/\./, $prev);
+ $prev = $t;
+ if ( $prefix ) {
+ $t =~ s/^$prefix\./-./;
+ }
+ $query .= " " . $t;
+ }
+ }
+
+ # die $orig_query if $query eq 'LOCK lock';
+ return $query;
+}
+
# secs_to_time {{{3
sub secs_to_time {
my ( $secs, $fmt ) = @_;
$secs ||= 0;
- return '00:00' unless $secs;
+
+ # If the inbound value has a decimal point, then format the seconds with milliseconds.
+ my $hires = $secs =~ m/\./ ? '%06.3f' : '%02d';
+
+ if ( !$secs ) {
+ return sprintf("00:$hires", $secs);
+ }
# Decide what format to use, if not given
$fmt ||= $secs >= 86_400 ? 'd'
@@ -6253,20 +7217,20 @@ sub secs_to_time {
return
$fmt eq 'd' ? sprintf(
- "%d+%02d:%02d:%02d",
+ "%d+%02d:%02d:$hires",
int($secs / 86_400),
int(($secs % 86_400) / 3_600),
int(($secs % 3_600) / 60),
- $secs % 60)
+ $secs % 60 + ($secs - int($secs)))
: $fmt eq 'h' ? sprintf(
- "%02d:%02d:%02d",
+ "%02d:%02d:$hires",
int(($secs % 86_400) / 3_600),
int(($secs % 3_600) / 60),
- $secs % 60)
+ $secs % 60 + ($secs - int($secs)))
: sprintf(
- "%02d:%02d",
+ "%02d:$hires",
int(($secs % 3_600) / 60),
- $secs % 60);
+ $secs % 60 + ($secs - int($secs)));
}
# dulint_to_int {{{3
@@ -6300,13 +7264,13 @@ sub create_statusbar {
else {
if ( $modes{$mode}->{server_group} ) {
$cxn = "Servers: " . $modes{$mode}->{server_group};
- my $err_count = grep { $dbhs{$_} && $dbhs{$_}->{err_count} } @cxns;
+ my $err_count = grep { $dbhs{$_} && $dbhs{$_}->{failed} } @cxns;
if ( $err_count ) {
$cxn .= "(" . ( scalar(@cxns) - $err_count ) . "/" . scalar(@cxns) . ")";
}
}
else {
- $cxn = join(' ', map { ($dbhs{$_}->{err_count} ? '!' : '') . $_ }
+ $cxn = join(' ', map { ($dbhs{$_}->{failed} ? '!' : '') . $_ }
grep { $dbhs{$_} } @cxns);
}
}
@@ -6317,7 +7281,7 @@ sub create_statusbar {
my $inc = inc(0, $cxns[0]);
# Format server uptime human-readably, calculate QPS...
- my $uptime = secs_to_time( $vars->{Uptime_hires} );
+ my $uptime = fuzzy_time( $vars->{Uptime_hires} );
my $qps = ($inc->{Questions}||0) / ($inc->{Uptime_hires}||1);
my $ibinfo = '';
@@ -6502,6 +7466,18 @@ sub get_connections {
if ( $modes{$mode}->{one_connection} ) {
@connections = @connections ? $connections[0] : ();
}
+ # If the connections are the same as a server group, we set the mode's
+ # group to that group.
+ if ( ! $modes{$mode}->{server_group} ) {
+ my $maybe_group = join(',', sort @connections);
+ foreach my $g ( keys %server_groups ) {
+ my $group_conns = join(',', sort @{$server_groups{$g}});
+ if ( $maybe_group eq $group_conns ) {
+ $modes{$mode}->{server_group} = $g;
+ last;
+ }
+ }
+ }
return unique(@connections);
}
@@ -6530,7 +7506,7 @@ sub choose_connections {
my $choices = prompt_list("Choose connections or a group for $mode mode",
undef, sub { return keys %$meta }, $meta);
- my @choices = unique(grep { $_ } split(/\s+/, $choices));
+ my @choices = unique(grep { $_ } $choices =~ m/(\S+)/g);
if ( @choices ) {
if ( $choices[0] =~ s/^#// && exists $server_groups{$choices[0]} ) {
$modes{$mode}->{server_group} = $choices[0];
@@ -6553,9 +7529,8 @@ sub do_stmt {
# Test if the cxn should not even be tried
return undef if $dbhs{$cxn}
- && $dbhs{$cxn}->{err_count}
- && ( !$dbhs{$cxn}->{dbh} || !$dbhs{$cxn}->{dbh}->{Active} || $dbhs{$cxn}->{mode} eq $config{mode}->{val} )
- && $dbhs{$cxn}->{wake_up} > $clock;
+ && $dbhs{$cxn}->{failed}
+ && ( !$dbhs{$cxn}->{dbh} || !$dbhs{$cxn}->{dbh}->{Active} || $dbhs{$cxn}->{mode} eq $config{mode}->{val} );
my $sth;
my $retries = 1;
@@ -6596,13 +7571,12 @@ sub do_stmt {
}
}
-# Keeps track of error count, sleep times till retries, etc etc.
-# When there's an error we retry the connection every so often, increasing in
-# Fibonacci series to prevent too much banging on the server.
+# Marks a connection as failed. When we sleep between redraws, we try to
+# reopen.
sub handle_cxn_error {
my ( $cxn, $err ) = @_;
my $meta = $dbhs{$cxn};
- $meta->{err_count}++;
+ $meta->{failed} = 1;
# This is used so errors that have to do with permissions needed by the current
# mode will get displayed as long as we're in this mode, but get ignored if the
@@ -6616,12 +7590,8 @@ sub handle_cxn_error {
}
$meta->{last_err} = $err;
- my $sleep_time = $meta->{this_sleep} + $meta->{prev_sleep};
- $meta->{prev_sleep} = $meta->{this_sleep};
- $meta->{this_sleep} = $sleep_time;
- $meta->{wake_up} = $clock + $sleep_time;
if ( $config{show_cxn_errors}->{val} ) {
- print STDERR "Error at tick $clock $cxn $err" if $config{debug}->{val};
+ print STDERR "DB error: $cxn $err" if $config{debug}->{val};
}
}
@@ -6634,9 +7604,8 @@ sub do_query {
# Test if the cxn should not even be tried
return undef if $dbhs{$cxn}
- && $dbhs{$cxn}->{err_count}
- && ( !$dbhs{$cxn}->{dbh} || !$dbhs{$cxn}->{dbh}->{Active} || $dbhs{$cxn}->{mode} eq $config{mode}->{val} )
- && $dbhs{$cxn}->{wake_up} > $clock;
+ && $dbhs{$cxn}->{failed}
+ && ( !$dbhs{$cxn}->{dbh} || !$dbhs{$cxn}->{dbh}->{Active} || $dbhs{$cxn}->{mode} eq $config{mode}->{val} );
my $sth;
my $retries = 1;
@@ -6679,9 +7648,6 @@ sub connect_to_db {
$dbhs{$cxn} ||= {
stmts => {}, # bucket for prepared statements.
- prev_sleep => 0,
- this_sleep => 1,
- wake_up => 0,
start_time => 0,
dbh => undef,
};
@@ -6689,8 +7655,7 @@ sub connect_to_db {
if ( !$href->{dbh} || ref($href->{dbh}) !~ m/DBI/ || !$href->{dbh}->ping ) {
my $dbh = get_new_db_connection($cxn);
- @{$href}{qw(dbh err_count wake_up this_sleep start_time prev_sleep)}
- = ($dbh, 0, 0, 1, 0, 0);
+ @{$href}{qw(dbh failed start_time stmts)} = ($dbh, 0, 0, {});
# Derive and store the server's start time in hi-res
my $uptime = $dbh->selectrow_hashref("show status like 'Uptime'")->{value};
@@ -6709,7 +7674,7 @@ sub connect_to_db {
# Compares versions like 5.0.27 and 4.1.15-standard-log
sub version_ge {
my ( $dbh, $target ) = @_;
- my $version = sprintf('%03d%03d%03d', $dbh->{mysql_serverinfo} =~ m/(\d+)/g);
+ my $version = sprintf('%03d%03d%03d', $dbh->{mysql_serverinfo} =~ m/^(\d+).(\d+).(\d+)/g);
return $version ge sprintf('%03d%03d%03d', $target =~ m/(\d+)/g);
}
@@ -6781,7 +7746,7 @@ sub get_cxn_errors {
return () unless $config{show_cxn_errors_in_tbl}->{val};
return
map { [ $_ . ': ' . $dbhs{$_}->{last_err}, 'red' ] }
- grep { $dbhs{$_} && $dbhs{$_}->{err_count} && $dbhs{$_}->{mode} eq $config{mode}->{val} }
+ grep { $dbhs{$_} && $dbhs{$_}->{failed} && $dbhs{$_}->{mode} eq $config{mode}->{val} }
@cxns;
}
@@ -6868,6 +7833,15 @@ sub compile_expr {
# This is a subroutine because it's called from a key to quit the program.
sub finish {
save_config();
+ foreach my $cxn ( values %dbhs ) {
+ eval {
+ foreach my $sth ( values %{$cxn->{stmts}} ) {
+ $sth->finish;
+ }
+ $cxn->{dbh}->disconnect;
+ };
+ # Ignore eval errors, we just don't care
+ }
ReadMode('normal') unless $opts{n};
print "\n";
exit(0);
@@ -6926,7 +7900,7 @@ sub load_config {
my ($old_filename, $answer);
- if ( $opts{u} or $opts{p} or $opts{h} or $opts{P} ) {
+ if ( $opts{u} or $opts{p} or $opts{h} or $opts{P} or $opts{S} ) {
my @params = $dsn_parser->get_cxn_params(\%opts); # dsn=$params[0]
add_new_dsn($opts{h} || 'localhost', $params[0], 'test.innotop_dl',
$opts{u} ? 1 : 0, $opts{u}, $opts{p} ? 1 : 0, $opts{p});
@@ -6934,8 +7908,10 @@ sub load_config {
if ($opts{c}) {
$conf_file = $opts{c};
}
- # innotop got upgraded and this is an old config file.
- elsif ( -f "$homepath/.innotop" or -f "$homepath/.innotop/innotop.ini" ) {
+ # If we don't have a new config file but we do have an old one,
+ # innotop got upgraded and this is an old config file. Convert it, but
+ # don't overwrite something existing.
+ elsif ( ! -f $default_home_conf && ( -f "$homepath/.innotop" or -f "$homepath/.innotop/innotop.ini" ) ) {
$conf_file = $default_home_conf;
if ( -f "$homepath/.innotop") {
$old_filename = "$homepath/.innotop";
@@ -7462,7 +8438,8 @@ sub load_config_tbl_meta {
foreach my $prop ( keys %col_props ) {
if ( !defined($parts{$prop}) ) {
- die "Undefined property $prop for column $col in table $tbl";
+ # Make it default to whatever's in col_props.
+ $parts{$prop} = $col_props{$prop};
}
# Un-escape escaping
@@ -7997,6 +8974,17 @@ sub choose_mode_tables {
$modes{$mode}->{cust}->{visible_tables} = 1;
}
+# set_visible_table {{{3
+sub set_visible_table {
+ my ( $tbl ) = @_;
+ my $mode = $config{mode}->{val};
+ my @tbls = grep { $_ eq $tbl } @{$modes{$mode}->{tables}};
+ if ( @tbls == 1 ) {
+ $modes{$mode}->{visible_tables} = [ $tbl ];
+ $modes{$mode}->{cust}->{visible_tables} = 1;
+ }
+}
+
# choose_visible_table {{{3
sub choose_visible_table {
my ( $grep_cond ) = @_;
@@ -8045,7 +9033,7 @@ sub choose_filters {
}
);
- my @choices = unique(split(/\s+/, $val));
+ my @choices = unique($val =~ m/(\S+)/g);
foreach my $new ( grep { !exists($filters{$_}) } @choices ) {
my $answer = prompt("There is no filter called '$new'. Create it?", undef, 'y');
if ( $answer eq 'y' ) {
@@ -8290,7 +9278,7 @@ sub choose_or_create_connection {
sub { return @available },
{ map { $_ => $connections{$_}->{dsn} } @available });
- my @new = unique(grep { !exists $connections{$_} } split(/\s+/, $new_cxns));
+ my @new = unique(grep { !exists $connections{$_} } $new_cxns =~ m/(\S+)/g);
foreach my $new ( @new ) {
my $answer = prompt("There is no connection called '$new'. Create it?", undef, "y");
if ( $answer eq 'y' ) {
@@ -8309,6 +9297,7 @@ sub choose_servers {
my @chosen = choose_or_create_connection($cxns, 'for this mode');
$modes{$mode}->{connections} = \@chosen;
$modes{$mode}->{server_group} = ''; # Clear this because it overrides {connections}
+ get_connections(); # This will set the server group if it matches connections just chosen
}
# display_license {{{3
@@ -8339,10 +9328,41 @@ sub get_status_info {
$vars->{Uptime_hires} ||= get_uptime($cxn);
$vars->{cxn} = $cxn;
- # Add SHOW VARIABLES to the hash
- $sth = do_stmt($cxn, 'SHOW_VARIABLES') or next;
- $res = $sth->fetchall_arrayref();
- map { $vars->{$_->[0]} = $_->[1] || 0 } @$res;
+ # Add SHOW VARIABLES to the hash. If we've gotten this info before, skip and re-use.
+ if ( $show_variables{$cxn} ) {
+ $res = $show_variables{$cxn};
+ }
+ else {
+ $sth = do_stmt($cxn, 'SHOW_VARIABLES') or next;
+ $res = $sth->fetchall_arrayref();
+ $res = {map { $_->[0] => $_->[1] || 0 } @$res};
+ $show_variables{$cxn} = $res;
+ }
+ @{$vars}{keys %$res} = values %$res;
+
+ # Create sparklines for QPS and Threads_running. As a consequence of
+ # this, we get QPS for free. TODO: remove QPS computation from
+ # elsewhere.
+ my $pre = $vars{$cxn}->{$clock - 1};
+ if ( $pre && $pre->{Uptime_hires} ) {
+ my @prev_qps = ($pre->{SPARK_store_qps} || '') =~ m/(\S+)/g;
+ my @prev_run = ($pre->{SPARK_store_run} || '') =~ m/(\S+)/g;
+
+ # Find out the values; throw away if too many; sparkify; store.
+ my $this_qps = (($vars->{Questions} || 0) - ($pre->{Questions} || 0))/
+ ($vars->{Uptime_hires} - $pre->{Uptime_hires});
+ push @prev_qps, $this_qps;
+ shift @prev_qps if @prev_qps > $config{spark}->{val};
+ my $qps_spark = sparkify(@prev_qps);
+ $vars->{SPARK_qps} = $qps_spark;
+ $vars->{SPARK_store_qps} = join(' ', @prev_qps);
+ my $this_run = $vars->{Threads_running};
+ push @prev_run, $this_run;
+ shift @prev_run if @prev_run > $config{spark}->{val};
+ my $run_spark = sparkify(@prev_run);
+ $vars->{SPARK_run} = $run_spark;
+ $vars->{SPARK_store_run} = join(' ', @prev_run);
+ }
}
}
}
@@ -8352,7 +9372,6 @@ sub get_status_info {
sub choose_thread {
my ( $grep_cond, $prompt ) = @_;
- # Narrow the list to queries that can be explained.
my %thread_for = map {
# Eliminate innotop's own threads.
$_ => $dbhs{$_}->{dbh} ? $dbhs{$_}->{dbh}->{mysql_thread_id} : 0
@@ -8380,7 +9399,7 @@ sub choose_thread {
my ( $a, $b ) = @_;
return $a->{query} && !$b->{query} ? 1
: $b->{query} && !$a->{query} ? -1
- : ($a->{time} || 0) <=> ($b->{time} || 0);
+ : ($a->{time} || 0) cmp ($b->{time} || 0);
};
my @threads = map { $_->{id} } reverse sort { $sort_func->($a, $b) } @candidates;
@@ -8439,7 +9458,7 @@ sub inc {
# Numeric variables get subtracted, non-numeric get passed straight through.
map {
$_ =>
- ( (defined $cur->{$_} && $cur->{$_} =~ m/$num_regex/)
+ ( (defined $cur->{$_} && $cur->{$_} =~ m/$num_regex/ && ($pre->{$_} || '') =~ m/$num_regex/ )
? $cur->{$_} - ($pre->{$_} || 0)
: $cur->{$_} )
} keys %{$cur}
@@ -8479,6 +9498,72 @@ sub extract_values {
return $result;
}
+# get_processlist_stats {{{3
+# Inserts special values as though they are SHOW STATUS counters.
+sub get_processlist_stats {
+ my @cxns = @_;
+ @current_queries = ();
+ if ( !$info_gotten{processlist_stats}++ ) {
+ foreach my $cxn ( @cxns ) {
+ my $max_query_time = 0;
+ my ($user_threads, $slaves, $longest_sql, $slave_sql, $locked);
+ $vars{$cxn}->{$clock} ||= {};
+ my $vars = $vars{$cxn}->{$clock};
+ $vars->{cxn} = $cxn;
+ my $stmt = do_stmt($cxn, 'PROCESSLIST_NO_IS') or next;
+ my $arr = $stmt->fetchall_arrayref({});
+ my $cur = undef;
+ foreach my $thread ( @$arr ) {
+ if ( ($thread->{state} || '') =~ m/lock/i ) {
+ $locked++;
+ }
+ # Ignore non-user threads, but remember the SQL in case there is
+ # no user SQL. Ignore sleeping threads and SHOW PROCESSLIST
+ # threads.
+ if ( ($thread->{user} || '') =~ m/system user/ ) {
+ if ( $thread->{info} && $thread->{time} ) {
+ $slave_sql = $thread->{info};
+ }
+ next;
+ }
+ next unless $thread->{command};
+ if ( $thread->{command} eq 'Binlog Dump' ) {
+ $slaves++;
+ next;
+ }
+ next unless $thread->{command} eq 'Query';
+ next unless $thread->{state} && $thread->{info};
+ next if $thread->{info} =~ m#/\*innotop#;
+ $user_threads++;
+ if ( $thread->{time} > $max_query_time ) {
+ $max_query_time = $thread->{time};
+ $longest_sql = $thread->{info};
+ if ( $thread->{state} eq 'Checking table' ) {
+ $longest_sql = 'CHECK TABLE ' . $thread->{info};
+ }
+ $cur = {
+ cxn => $cxn,
+ id => $thread->{id},
+ db => $thread->{db},
+ query => $thread->{info},
+ time => $thread->{time},
+ user => $thread->{user},
+ host => $thread->{host},
+ };
+ $thread->{host} =~ s/:.*$//;
+ }
+ }
+ $vars->{Max_query_time} = $max_query_time;
+ $vars->{User_threads_running} = $user_threads;
+ $vars->{Slaves} = $slaves || 0;
+ $vars->{Longest_sql} = $longest_sql || $slave_sql || '';
+ $vars->{Locked_count} = $locked || 0;
+ $vars->{Uptime_hires} ||= get_uptime($cxn);
+ push @current_queries, $cur if $cur;
+ }
+ }
+}
+
# get_full_processlist {{{3
sub get_full_processlist {
my @cxns = @_;
@@ -8503,6 +9588,54 @@ sub get_open_tables {
return @result;
}
+# get_index_statistics {{{3
+sub get_index_statistics {
+ my @cxns = @_;
+ my @result;
+ foreach my $cxn ( @cxns ) {
+ my $stmt = do_stmt($cxn, 'INDEX_STATISTICS') or next;
+ my $arr = $stmt->fetchall_arrayref({});
+ push @result, map { $_->{cxn} = $cxn; $_ } @$arr;
+ }
+ return @result;
+}
+
+# get_index_table_statistics {{{3
+sub get_index_table_statistics {
+ my @cxns = @_;
+ my @result;
+ foreach my $cxn ( @cxns ) {
+ my $stmt = do_stmt($cxn, 'INDEX_TABLE_STATISTICS') or next;
+ my $arr = $stmt->fetchall_arrayref({});
+ push @result, map { $_->{cxn} = $cxn; $_ } @$arr;
+ }
+ return @result;
+}
+
+# get_table_statistics {{{3
+sub get_table_statistics {
+ my @cxns = @_;
+ my @result;
+ foreach my $cxn ( @cxns ) {
+ my $stmt = do_stmt($cxn, 'TABLE_STATISTICS') or next;
+ my $arr = $stmt->fetchall_arrayref({});
+ push @result, map { $_->{cxn} = $cxn; $_ } @$arr;
+ }
+ return @result;
+}
+
+# get_innodb_blocked_blocker {{{3
+sub get_innodb_blocked_blocker {
+ my @cxns = @_;
+ my @result;
+ foreach my $cxn ( @cxns ) {
+ my $stmt = do_stmt($cxn, 'INNODB_BLOCKED_BLOCKER') or next;
+ my $arr = $stmt->fetchall_arrayref({});
+ push @result, map { $_->{cxn} = $cxn; $_ } @$arr;
+ }
+ return @result;
+}
+
# get_innodb_status {{{3
sub get_innodb_status {
my ( $cxns, $addl_sections ) = @_;
@@ -8549,6 +9682,7 @@ sub get_innodb_status {
}
else {
+ next if ($show_variables{$cxn}->{have_innodb} || 'YES') eq 'NO';
my $stmt = do_stmt($cxn, 'INNODB_STATUS') or next;
$innodb_status_text = $stmt->fetchrow_hashref()->{status};
}
@@ -8563,6 +9697,7 @@ sub get_innodb_status {
$config{debug}->{val},
\%sections_required,
0, # don't parse full lock information
+ $show_variables{$cxn}->{version}
)
);
if ( !$innodb_status{IB_got_all} && $config{auto_wipe_dl}->{val} ) {
@@ -8587,6 +9722,9 @@ sub clear_deadlock {
return unless $tbl;
eval {
+ # disable binary logging for the session
+ do_query($cxn, "set SQL_LOG_BIN=0");
+
# Set up the table for creating a deadlock.
my $engine = version_ge($dbhs{$cxn}->{dbh}, '4.1.2') ? 'engine' : 'type';
return unless do_query($cxn, "drop table if exists $tbl");
@@ -8616,6 +9754,11 @@ sub clear_deadlock {
# Clean up.
do_query($cxn, "drop table $tbl");
+
+ # enable binary logging for the session again
+ # the session by itself will not be used anymore, but this is clean :)
+ do_query($cxn, "set SQL_LOG_BIN=1");
+
};
if ( $EVAL_ERROR ) {
print $EVAL_ERROR;
@@ -8638,6 +9781,7 @@ sub get_master_logs {
}
# get_master_slave_status {{{3
+# Inserts special counters as though they are SHOW STATUS counters.
sub get_master_slave_status {
my @cxns = @_;
if ( !$info_gotten{replication_status}++ ) {
@@ -8645,18 +9789,61 @@ sub get_master_slave_status {
$vars{$cxn}->{$clock} ||= {};
my $vars = $vars{$cxn}->{$clock};
$vars->{cxn} = $cxn;
+ $vars->{Uptime_hires} ||= get_uptime($cxn);
my $stmt = do_stmt($cxn, 'SHOW_MASTER_STATUS') or next;
my $res = $stmt->fetchall_arrayref({})->[0];
@{$vars}{ keys %$res } = values %$res;
- $stmt = do_stmt($cxn, 'SHOW_SLAVE_STATUS') or next;
- $res = $stmt->fetchall_arrayref({})->[0];
- @{$vars}{ keys %$res } = values %$res;
- $vars->{Uptime_hires} ||= get_uptime($cxn);
+
}
}
}
+# get_slave_status {{{3
+# Separated handling of slave status to support 5.7 and replication channels
+sub get_slave_status {
+ my ($cxn, $channel) = @_;
+ my $chcxn = $channel . '=' . $cxn;
+ $vars{$chcxn}->{$clock} ||= {};
+ my $vars = $vars{$chcxn}->{$clock};
+ $vars->{chcxn} = $chcxn;
+ $vars->{Uptime_hires} ||= get_uptime($chcxn);
+
+ if ( $channel =~ /no_channels/ ) {
+ my $stmt = do_stmt($cxn, 'SHOW_SLAVE_STATUS') or next;
+ my $res = $stmt->fetchall_arrayref({});
+ if ( $res && @$res ) {
+ $res = $res->[0];
+ @{$vars}{ keys %$res } = values %$res;
+ $vars->{Slave_ok} =
+ (($res->{slave_sql_running} || 'Yes') eq 'Yes'
+ && ($res->{slave_io_running} || 'Yes') eq 'Yes') ? 'Yes' : 'No';
+ }
+ else {
+ $vars->{Slave_ok} = 'Off';
+ }
+ } else {
+ my $dbh = connect_to_db($cxn);
+ my $sql = 'SHOW SLAVE STATUS FOR CHANNEL \'' . $channel . '\'';
+ my $stmt = $dbh->prepare($sql ) ;
+ $stmt->execute();
+ my $res = $stmt->fetchall_arrayref({});
+ if ( $res && @$res ) {
+ $res = $res->[0];
+ @{$vars}{ keys %$res } = values %$res;
+ $vars->{Slave_ok} =
+ (($res->{slave_sql_running} || 'Yes') eq 'Yes'
+ && ($res->{slave_io_running} || 'Yes') eq 'Yes') ? 'Yes' : 'No';
+ }
+ else {
+ $vars->{Slave_ok} = 'Off';
+ }
+ }
+ }
+
+
+
+
sub is_func {
my ( $word ) = @_;
return defined(&$word)
@@ -8811,6 +9998,12 @@ Port to use for connection.
Don't read the central configuration file.
+=item --timestamp
+
+In -n mode, write a timestamp either before every screenful of output, or if
+the option is given twice, at the start of every line. The format is controlled
+by the timeformat config variable.
+
=item --user
User to use for connection.
@@ -8860,6 +10053,13 @@ following list:
=over
+=item A: Health Dashboard
+
+This mode displays a single table with one row per monitored server. The
+columns show essential overview information about the server's health, and
+coloration rules show whether replication is running or if there are any very
+long-running queries or excessive replication delay.
+
=item B: InnoDB Buffers
This mode displays information about the InnoDB buffer pool, page statistics,
@@ -8945,6 +10145,12 @@ This mode shows InnoDB's I/O statistics, including the I/O threads, pending I/O,
file I/O miscellaneous, and log statistics. It displays the L<"io_threads">,
L<"pending_io">, L<"file_io_misc">, and L<"log_statistics"> tables by default.
+=item K: InnoDB Lock Waits
+
+This mode shows information from InnoDB plugin's transaction and locking tables.
+You can use it to find when a transaction is waiting for another, and kill the
+blocking transaction. It displays the L<"innodb_blocked_blocker>" table.
+
=item L: Locks
This mode shows information about current locks. At the moment only InnoDB
@@ -9008,6 +10214,23 @@ tables might be locked implicitly.
This mode displays the L<"open_tables"> mode by default.
+=item U: User Statistics
+
+This mode displays data that's available in Percona's enhanced version of MySQL
+(also known as Percona Server with XtraDB). Specifically, it makes it easy to
+enable and disable the so-called "user statistics." This feature gathers stats
+on clients, threads, users, tables, and indexes and makes them available as
+INFORMATION_SCHEMA tables. These are invaluable for understanding what your
+server is doing. They are also available in MariaDB.
+
+The statistics supported so far are only from the TABLE_STATISTICS and
+INDEX_STATISTICS tables added by Percona. There are three views: one of table stats,
+one of index stats (which can be aggregated with the = key), and one of both.
+
+The server doesn't gather these stats by default. You have to set the variable
+userstat_running to turn it on. You can do this easily with innotop from U mode,
+with the 's' key.
+
=item Q: Query List
This mode displays the output from SHOW FULL PROCESSLIST, much like B's
@@ -9156,6 +10379,9 @@ connection names of that master's slaves (there is no way for innotop to
determine this reliably itself). innotop will find the minimum binlog in use by
these slave connections and suggest it as the argument to PURGE MASTER LOGS.
+in L<"U: User Statistics"> mode, you can use the 's' key to start and stop
+the collection of the statistics data for TABLE_STATISTICS and similar.
+
=head1 SERVER CONNECTIONS
When you create a server connection using '@', innotop asks you for a series of
@@ -9603,6 +10829,11 @@ Disables fetching SHOW INNODB STATUS, in case your server(s) do not have InnoDB
enabled and you don't want innotop to try to fetch it. This can also be useful
when you don't have the SUPER privilege, required to run SHOW INNODB STATUS.
+=item spark
+
+Specifies how wide a spark chart is. There are two ASCII spark charts in A
+mode, showing QPS and User_threads_running.
+
=item status_inc
Whether to show absolute or incremental values for status variables.
@@ -9611,6 +10842,11 @@ for that variable. This is a global setting, but will probably become
mode-specific at some point. Right now it is honored a bit inconsistently; some
modes don't pay attention to it.
+=item timeformat
+
+The C-style strftime()-compatible format for the timestamp line to be printed
+in -n mode when -t is set.
+
=back
=item plugins
@@ -9874,6 +11110,27 @@ L<"STATUS_VARIABLES">.
Displays various data about InnoDB's last foreign key error. Data source:
L<"STATUS_VARIABLES">.
+=item health_dashboard
+
+Displays an overall summary of servers, one server per line, for monitoring.
+Data source: L<"STATUS_VARIABLES">, L<"MASTER_SLAVE">, L<"PROCESSLIST_STATS">.
+
+=item index_statistics
+
+Displays data from the INDEX_STATISTICS table in Percona-enhanced servers.
+
+=item index_table_statistics
+
+Displays data from the INDEX_STATISTICS and TABLE_STATISTICS tables in
+Percona-enhanced servers. It joins the two together, grouped by the database
+and table name. It is the default view in L<"U: User Statistics"> mode,
+and makes it easy to see what tables are hot, how many rows are read from indexes,
+how many changes are made, and how many changes are made to indexes.
+
+=item innodb_blocked_blocker
+
+Displays InnoDB locks and lock waits. Data source: L<"INNODB_BLOCKED_BLOCKER">.
+
=item innodb_locks
Displays InnoDB locks. Data source: L<"INNODB_LOCKS">.
@@ -9944,6 +11201,10 @@ L<"STATUS_VARIABLES">.
Displays data about the slave SQL thread. Data source: L<"STATUS_VARIABLES">.
+=item table_statistics
+
+Displays data from the TABLE_STATISTICS table in Percona-enhanced servers.
+
=item t_header
Displays various InnoDB status values. Data source: L<"STATUS_VARIABLES">.
@@ -10021,6 +11282,10 @@ the table. Several columns are set this way, such as the count column on
L<"processlist"> and L<"innodb_transactions">, so you don't see a count when the
grouping isn't enabled, but you do when it is.
+=item *
+
+agghide: the reverse of aggonly. The column is hidden when grouping is enabled.
+
=back
=head2 FILTERS
@@ -10072,11 +11337,26 @@ persist when you restart innotop. To create a quick-filter, press the '/' key.
innotop will prompt you for the column name and filter text. Again, you can use
auto-completion on column names. The filter text can be just the text you want
to "search for." For example, to filter the L<"processlist"> table on queries
-that refer to the products table, type '/' and then 'info product'.
+that refer to the products table, type '/' and then 'info product'. Internally,
+the filter is compiled into a subroutine like this:
+
+ sub filter {
+ my ( $set ) = @_;
+ $set->{info} =~ m/product/;
+ }
The filter text can actually be any Perl regular expression, but of course a
literal string like 'product' works fine as a regular expression.
+What if you want the filter to discard matching rows, rather than showing
+matching rows? If you're familiar with Perl regular expressions, you might
+guess how to do this. You have to use a zero-width negative lookahead
+assertion. If you don't know what that means, don't worry. Let's filter out
+all rows where the command is Gandalf. Type the following:
+
+ 1. /
+ 2. cmd ^(?!Gandalf)
+
Behind the scenes innotop compiles the quick-filter into a specially tagged
filter that is otherwise like any other filter. It just isn't saved to the
configuration file.
@@ -10174,8 +11454,8 @@ That's actually quite a worrisome picture. You've got a lot of idle connections
(Sleep), and some connections executing queries (Query and Sending Data).
That's okay, but you also have a lot in Statistics status, collectively spending
over a minute. That means the query optimizer is having a really hard time
-optimizing your statements. Something is wrong; it should normally take
-milliseconds to optimize queries. You might not have seen this pattern if you
+generating execution plans for your statements. Something is wrong; it should
+normally take milliseconds to plan queries. You might not have seen this pattern if you
didn't look at your connections in aggregate. (This is a made-up example, but
it can happen in real life).
@@ -10311,12 +11591,20 @@ are defined:
Adds commas to large numbers every three decimal places.
+=item distill
+
+Distills SQL into verb-noun-noun format for quick comprehension.
+
=item dulint_to_int
Accepts two unsigned integers and converts them into a single longlong. This is
useful for certain operations with InnoDB, which uses two integers as
transaction identifiers, for example.
+=item fuzzy_time
+
+Converts a number of seconds into a friendly, readable value like "1h35m".
+
=item no_ctrl_char
Removes quoted control characters from the value. This is affected by the
@@ -10365,7 +11653,7 @@ show you something like this:
pages_modified Dirty Pages Pages modified (dirty IB_bp_pages_m
buf_pool_hit_rate Hit Rate Buffer pool hit rate IB_bp_buf_poo
total_mem_alloc Memory Total memory allocate IB_bp_total_m
- add_pool_alloc Add'l Pool Additional pool alloca IB_bp_add_poo
+ add_pool_alloc Add'l Pool Additonal pool alloca IB_bp_add_poo
The first line shows which table you're editing, and reminds you again to press
'?' for a list of key mappings. The rest is a tabular representation of the
@@ -10485,9 +11773,9 @@ or modify its existing functionality, and add new functionality. innotop's
plugin functionality is event-based: plugins register themselves to be called
when events happen. They then have a chance to influence the event.
-An innotop plugin is a Perl module placed in innotop's L<"plugin_dir">
+An innotop plugin is a Perl module (.pm) file placed in innotop's L<"plugin_dir">
directory. On UNIX systems, you can place a symbolic link to the module instead
-of putting the actual file there. innotop automatically discovers the file. If
+of putting the actual file there. innotop automatically discovers files named C<*.pm>. If
there is a corresponding entry in the L<"plugins"> configuration file section,
innotop loads and activates the plugin.
@@ -10500,7 +11788,7 @@ file and determine the package name and description.
innotop inspects the plugin module's source to determine the Perl package name.
It looks for a line of the form "package Foo;" and if found, considers the
plugin's package name to be Foo. Of course the package name can be a valid Perl
-package name, with double semicolons and so on.
+package name such as Foo::Bar, with double colons (::) and so on.
It also looks for a description in the source code, to make the plugin editor
more human-friendly. The description is a comment line of the form "#
@@ -10642,7 +11930,9 @@ $lines is an arrayref of strings.
The easiest way to explain the plugin functionality is probably with a simple
example. The following module adds a column to the beginning of every table and
-sets its value to 1.
+sets its value to 1. (If you copy and paste this example code, be sure to remove
+the first space from each line; lines such as '# description' must not start with
+whitespace).
use strict;
use warnings FATAL => 'all';
@@ -10716,6 +12006,7 @@ executes "SHOW ENGINE INNODB STATUS", while on earlier versions it executes
Statement SQL executed
=================== ===============================
+ INDEX_STATISTICS SELECT * FROM INFORMATION_SCHEMA.INDEX_STATISTICS
INNODB_STATUS SHOW [ENGINE] INNODB STATUS
KILL_CONNECTION KILL
KILL_QUERY KILL QUERY
@@ -10726,6 +12017,7 @@ executes "SHOW ENGINE INNODB STATUS", while on earlier versions it executes
SHOW_SLAVE_STATUS SHOW SLAVE STATUS
SHOW_STATUS SHOW [GLOBAL] STATUS
SHOW_VARIABLES SHOW [GLOBAL] VARIABLES
+ TABLE_STATISTICS SELECT * FROM INFORMATION_SCHEMA.TABLE_STATISTICS
=head1 DATA SOURCES
@@ -10766,6 +12058,11 @@ section of SHOW INNODB STATUS. It is nested one level deep.
This data is from the result set returned by EXPLAIN.
+=item INNODB_BLOCKED_BLOCKER
+
+This data is from the INFORMATION_SCHEMA tables related to InnoDB locks and
+the processlist.
+
=item INNODB_TRANSACTIONS
This data is from the TRANSACTIONS section of SHOW INNODB STATUS.
@@ -10780,6 +12077,10 @@ STATUS.
This data is from the TRANSACTIONS section of SHOW INNODB STATUS and is nested
two levels deep.
+=item MASTER_SLAVE
+
+This data is from the combination of SHOW MASTER STATUS and SHOW SLAVE STATUS.
+
=item OPEN_TABLES
This data is from SHOW OPEN TABLES.
@@ -10788,6 +12089,12 @@ This data is from SHOW OPEN TABLES.
This data is from SHOW FULL PROCESSLIST.
+=item PROCESSLIST_STATS
+
+This data is from SHOW FULL PROCESSLIST and computes stats such as the maximum time
+a user query has been running, and how many user queries are running. A "user
+query" excludes replication threads.
+
=item OS_WAIT_ARRAY
This data is from the SEMAPHORES section of SHOW INNODB STATUS and is nested one
@@ -10874,6 +12181,7 @@ displays it.
The following people and organizations are acknowledged for various reasons.
Hopefully no one has been forgotten.
+Aaron Racine,
Allen K. Smith,
Aurimas Mikalauskas,
Bartosz Fenski,
@@ -10937,7 +12245,7 @@ Originally written by Baron Schwartz; currently maintained by Aaron Racine.
=head1 BUGS
You can report bugs, ask for improvements, and get other help and support at
-L. There are mailing lists, a source code
+L. There are mailing lists, a source code
browser, a bug tracker, etc. Please use these instead of contacting the
maintainer or author directly, as it makes our job easier and benefits others if the
discussions are permanent and public. Of course, if you need to contact us in
diff --git a/debian/additions/innotop/innotop.1 b/debian/additions/innotop/innotop.1
index fbb481f9b94f8..7cd275a79f209 100644
--- a/debian/additions/innotop/innotop.1
+++ b/debian/additions/innotop/innotop.1
@@ -1,4 +1,4 @@
-.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.07)
+.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
@@ -38,6 +38,8 @@
. ds PI \(*p
. ds L" ``
. ds R" ''
+. ds C`
+. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
@@ -48,17 +50,24 @@
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
-.ie \nF \{\
-. de IX
-. tm Index:\\$1\t\\n%\t"\\$2"
+.\"
+.\" Avoid warning from groff about undefined register 'F'.
+.de IX
..
-. nr % 0
-. rr F
-.\}
-.el \{\
-. de IX
+.nr rF 0
+.if \n(.g .if rF .nr rF 1
+.if (\n(rF:(\n(.g==0)) \{
+. if \nF \{
+. de IX
+. tm Index:\\$1\t\\n%\t"\\$2"
..
+. if !\nF==2 \{
+. nr % 0
+. nr F 2
+. \}
+. \}
.\}
+.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
@@ -124,7 +133,7 @@
.\" ========================================================================
.\"
.IX Title "INNOTOP 1"
-.TH INNOTOP 1 "2009-03-09" "perl v5.10.0" "User Contributed Perl Documentation"
+.TH INNOTOP 1 "2017-01-23" "perl v5.20.2" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
@@ -210,7 +219,7 @@ To quit innotop, press the 'q' key.
.IX Header "OPTIONS"
innotop is mostly configured via its configuration file, but some of the
configuration options can come from the command line. You can also specify a
-file to monitor for InnoDB status output; see \*(L"\s-1MONITORING\s0 A \s-1FILE\s0\*(R" for more
+file to monitor for InnoDB status output; see \*(L"\s-1MONITORING A FILE\*(R"\s0 for more
details.
.PP
You can negate some options by prefixing the option name with \-\-no. For
@@ -249,7 +258,7 @@ Specifies the mode in which innotop should start. Corresponds to the
configuration option \*(L"mode\*(R".
.IP "\-\-nonint" 4
.IX Item "--nonint"
-Enable non-interactive operation. See \*(L"NON-INTERACTIVE \s-1OPERATION\s0\*(R" for more.
+Enable non-interactive operation. See \*(L"NON-INTERACTIVE \s-1OPERATION\*(R"\s0 for more.
.IP "\-\-password" 4
.IX Item "--password"
Password to use for connection.
@@ -259,6 +268,11 @@ Port to use for connection.
.IP "\-\-skipcentral" 4
.IX Item "--skipcentral"
Don't read the central configuration file.
+.IP "\-\-timestamp" 4
+.IX Item "--timestamp"
+In \-n mode, write a timestamp either before every screenful of output, or if
+the option is given twice, at the start of every line. The format is controlled
+by the timeformat config variable.
.IP "\-\-user" 4
.IX Item "--user"
User to use for connection.
@@ -289,10 +303,16 @@ the servers you're monitoring. You switch between modes with uppercase keys.
The following is a brief description of each mode, in alphabetical order. To
switch to the mode, press the key listed in front of its heading in the
following list:
+.IP "A: Health Dashboard" 4
+.IX Item "A: Health Dashboard"
+This mode displays a single table with one row per monitored server. The
+columns show essential overview information about the server's health, and
+coloration rules show whether replication is running or if there are any very
+long-running queries or excessive replication delay.
.IP "B: InnoDB Buffers" 4
.IX Item "B: InnoDB Buffers"
This mode displays information about the InnoDB buffer pool, page statistics,
-insert buffer, and adaptive hash index. The data comes from \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0.
+insert buffer, and adaptive hash index. The data comes from \s-1SHOW INNODB STATUS.\s0
.Sp
This mode contains the \*(L"buffer_pool\*(R", \*(L"page_statistics\*(R",
\&\*(L"insert_buffers\*(R", and \*(L"adaptive_hash_index\*(R" tables by default.
@@ -313,7 +333,7 @@ This mode is similar to mytop's Command Summary mode. It shows the
.Ve
.Sp
The command summary table is built by extracting variables from
-\&\*(L"\s-1STATUS_VARIABLES\s0\*(R". The variables must be numeric and must match the prefix
+\&\*(L"\s-1STATUS_VARIABLES\*(R"\s0. The variables must be numeric and must match the prefix
given by the \*(L"cmd_filter\*(R" configuration variable. The variables are then
sorted by value descending and compared to the last variable, as shown above.
The percentage columns are percentage of the total of all variables in the
@@ -322,7 +342,7 @@ table, so you can see the relative weight of the variables.
The example shows what you see if the prefix is \*(L"Select_\*(R". The default
prefix is \*(L"Com_\*(R". You can choose a prefix with the 's' key.
.Sp
-It's rather like running \s-1SHOW\s0 \s-1VARIABLES\s0 \s-1LIKE\s0 \*(L"prefix%\*(R" with memory and
+It's rather like running \s-1SHOW VARIABLES LIKE \s0\*(L"prefix%\*(R" with memory and
nice formatting.
.Sp
Values are aggregated across all servers. The Pct columns are not correctly
@@ -335,10 +355,10 @@ table shows the locks each transaction held and waited for. A deadlock is
caused by a cycle in the waits-for graph, so there should be two locks held and
one waited for unless the deadlock information is truncated.
.Sp
-InnoDB puts deadlock information before some other information in the \s-1SHOW\s0
-\&\s-1INNODB\s0 \s-1STATUS\s0 output. If there are a lot of locks, the deadlock information can
-grow very large, and there is a limit on the size of the \s-1SHOW\s0 \s-1INNODB\s0
-\&\s-1STATUS\s0 output. A large deadlock can fill the entire output, or even be
+InnoDB puts deadlock information before some other information in the \s-1SHOW
+INNODB STATUS\s0 output. If there are a lot of locks, the deadlock information can
+grow very large, and there is a limit on the size of the \s-1SHOW INNODB
+STATUS\s0 output. A large deadlock can fill the entire output, or even be
truncated, and prevent you from seeing other information at all. If you are
running innotop in another mode, for example T mode, and suddenly you don't see
anything, you might want to check and see if a deadlock has wiped out the data
@@ -346,8 +366,8 @@ you need.
.Sp
If it has, you can create a small deadlock to replace the large one. Use the
\&'w' key to 'wipe' the large deadlock with a small one. This will not work
-unless you have defined a deadlock table for the connection (see \*(L"\s-1SERVER\s0
-\&\s-1CONNECTIONS\s0\*(R").
+unless you have defined a deadlock table for the connection (see \*(L"\s-1SERVER
+CONNECTIONS\*(R"\s0).
.Sp
You can also configure innotop to automatically detect when a large deadlock
needs to be replaced with a small one (see \*(L"auto_wipe_dl\*(R").
@@ -371,6 +391,11 @@ This mode displays the \*(L"fk_error\*(R" table by default.
This mode shows InnoDB's I/O statistics, including the I/O threads, pending I/O,
file I/O miscellaneous, and log statistics. It displays the \*(L"io_threads\*(R",
\&\*(L"pending_io\*(R", \*(L"file_io_misc\*(R", and \*(L"log_statistics\*(R" tables by default.
+.IP "K: InnoDB Lock Waits" 4
+.IX Item "K: InnoDB Lock Waits"
+This mode shows information from InnoDB plugin's transaction and locking tables.
+You can use it to find when a transaction is waiting for another, and kill the
+blocking transaction. It displays the "innodb_blocked_blocker" table.
.IP "L: Locks" 4
.IX Item "L: Locks"
This mode shows information about current locks. At the moment only InnoDB
@@ -384,7 +409,7 @@ You can configure MySQL and innotop to monitor not only locks for which a
transaction is waiting, but those currently held, too. You can do this with the
InnoDB Lock Monitor (). It's
not documented in the MySQL manual, but creating the lock monitor with the
-following statement also affects the output of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0, which innotop
+following statement also affects the output of \s-1SHOW INNODB STATUS,\s0 which innotop
uses:
.Sp
.Vb 1
@@ -392,7 +417,7 @@ uses:
.Ve
.Sp
This causes InnoDB to print its output to the MySQL file every 16 seconds or so,
-as stated in the manual, but it also makes the normal \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0 output
+as stated in the manual, but it also makes the normal \s-1SHOW INNODB STATUS\s0 output
include lock information, which innotop can parse and display (that's the
undocumented feature).
.Sp
@@ -414,13 +439,13 @@ the screen when one connection is waiting for locks another connection holds:
\& localhost 11 RECORD 0 00:00 00:25 X test t1 PRIMARY
.Ve
.Sp
-You can see the first connection, \s-1ID\s0 12, is waiting for a lock on the \s-1PRIMARY\s0
+You can see the first connection, \s-1ID 12,\s0 is waiting for a lock on the \s-1PRIMARY\s0
key on test.t1, and has been waiting for 10 seconds. The second connection
isn't waiting, because the Waiting column is 0, but it holds locks on the same
index. That tells you connection 11 is blocking connection 12.
.IP "M: Master/Slave Replication Status" 4
.IX Item "M: Master/Slave Replication Status"
-This mode shows the output of \s-1SHOW\s0 \s-1SLAVE\s0 \s-1STATUS\s0 and \s-1SHOW\s0 \s-1MASTER\s0 \s-1STATUS\s0 in three
+This mode shows the output of \s-1SHOW SLAVE STATUS\s0 and \s-1SHOW MASTER STATUS\s0 in three
tables. The first two divide the slave's status into \s-1SQL\s0 and I/O thread status,
and the last shows master status. Filters are applied to eliminate non-slave
servers from the slave tables, and non-master servers from the master table.
@@ -429,15 +454,31 @@ This mode displays the \*(L"slave_sql_status\*(R", \*(L"slave_io_status\*(R", an
\&\*(L"master_status\*(R" tables by default.
.IP "O: Open Tables" 4
.IX Item "O: Open Tables"
-This section comes from MySQL's \s-1SHOW\s0 \s-1OPEN\s0 \s-1TABLES\s0 command. By default it is
+This section comes from MySQL's \s-1SHOW OPEN TABLES\s0 command. By default it is
filtered to show tables which are in use by one or more queries, so you can
get a quick look at which tables are 'hot'. You can use this to guess which
tables might be locked implicitly.
.Sp
This mode displays the \*(L"open_tables\*(R" mode by default.
+.IP "U: User Statistics" 4
+.IX Item "U: User Statistics"
+This mode displays data that's available in Percona's enhanced version of MySQL
+(also known as Percona Server with XtraDB). Specifically, it makes it easy to
+enable and disable the so-called \*(L"user statistics.\*(R" This feature gathers stats
+on clients, threads, users, tables, and indexes and makes them available as
+\&\s-1INFORMATION_SCHEMA\s0 tables. These are invaluable for understanding what your
+server is doing. They are also available in MariaDB.
+.Sp
+The statistics supported so far are only from the \s-1TABLE_STATISTICS\s0 and
+\&\s-1INDEX_STATISTICS\s0 tables added by Percona. There are three views: one of table stats,
+one of index stats (which can be aggregated with the = key), and one of both.
+.Sp
+The server doesn't gather these stats by default. You have to set the variable
+userstat_running to turn it on. You can do this easily with innotop from U mode,
+with the 's' key.
.IP "Q: Query List" 4
.IX Item "Q: Query List"
-This mode displays the output from \s-1SHOW\s0 \s-1FULL\s0 \s-1PROCESSLIST\s0, much like \fBmytop\fR's
+This mode displays the output from \s-1SHOW FULL PROCESSLIST,\s0 much like \fBmytop\fR's
query list mode. This mode does \fBnot\fR show InnoDB-related information. This
is probably one of the most useful modes for general usage.
.Sp
@@ -447,8 +488,8 @@ innotop hides inactive processes and its own process. You can toggle these on
and off with the 'i' and 'a' keys.
.Sp
You can \s-1EXPLAIN\s0 a query from this mode with the 'e' key. This displays the
-query's full text, the results of \s-1EXPLAIN\s0, and in newer MySQL versions, even
-the optimized query resulting from \s-1EXPLAIN\s0 \s-1EXTENDED\s0. innotop also tries to
+query's full text, the results of \s-1EXPLAIN,\s0 and in newer MySQL versions, even
+the optimized query resulting from \s-1EXPLAIN EXTENDED. \s0 innotop also tries to
rewrite certain queries to make them EXPLAIN-able. For example, \s-1INSERT/SELECT\s0
statements are rewritable.
.Sp
@@ -503,7 +544,7 @@ depends on the mode you're in, and what servers you're monitoring. The first
few words are always [\s-1RO\s0] (if readonly is set to 1), the innotop mode, such as
\&\*(L"InnoDB Txns\*(R" for T mode, followed by a reminder to press '?' for help at any
time.
-.SS "\s-1ONE\s0 \s-1SERVER\s0"
+.SS "\s-1ONE SERVER\s0"
.IX Subsection "ONE SERVER"
The simplest case is when you're monitoring a single server. In this case, the
name of the connection is next on the status line. This is the name you gave
@@ -511,9 +552,9 @@ when you created the connection \*(-- most likely the MySQL server's hostname.
This is followed by the server's uptime.
.PP
If you're in an InnoDB mode, such as T or B, the next word is \*(L"InnoDB\*(R" followed
-by some information about the \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0 output used to render the
-screen. The first word is the number of seconds since the last \s-1SHOW\s0 \s-1INNODB\s0
-\&\s-1STATUS\s0, which InnoDB uses to calculate some per-second statistics. The next is
+by some information about the \s-1SHOW INNODB STATUS\s0 output used to render the
+screen. The first word is the number of seconds since the last \s-1SHOW INNODB
+STATUS,\s0 which InnoDB uses to calculate some per-second statistics. The next is
a smiley face indicating whether the InnoDB output is truncated. If the smiley
face is a :\-), all is well; there is no truncation. A :^| means the transaction
list is so long, InnoDB has only printed out some of the transactions. Finally,
@@ -523,21 +564,21 @@ printing too much lock information (see \*(L"D: InnoDB Deadlocks\*(R").
The next two words indicate the server's queries per second (\s-1QPS\s0) and how many
threads (connections) exist. Finally, the server's version number is the last
thing on the line.
-.SS "\s-1MULTIPLE\s0 \s-1SERVERS\s0"
+.SS "\s-1MULTIPLE SERVERS\s0"
.IX Subsection "MULTIPLE SERVERS"
-If you are monitoring multiple servers (see \*(L"\s-1SERVER\s0 \s-1CONNECTIONS\s0\*(R"), the status
+If you are monitoring multiple servers (see \*(L"\s-1SERVER CONNECTIONS\*(R"\s0), the status
line does not show any details about individual servers. Instead, it shows the
names of the connections that are active. Again, these are connection names you
specified, which are likely to be the server's hostname. A connection that has
an error is prefixed with an exclamation point.
.PP
-If you are monitoring a group of servers (see \*(L"\s-1SERVER\s0 \s-1GROUPS\s0\*(R"), the status
+If you are monitoring a group of servers (see \*(L"\s-1SERVER GROUPS\*(R"\s0), the status
line shows the name of the group. If any connection in the group has an
error, the group's name is followed by the fraction of the connections that
don't have errors.
.PP
-See \*(L"\s-1ERROR\s0 \s-1HANDLING\s0\*(R" for more details about innotop's error handling.
-.SS "\s-1MONITORING\s0 A \s-1FILE\s0"
+See \*(L"\s-1ERROR HANDLING\*(R"\s0 for more details about innotop's error handling.
+.SS "\s-1MONITORING A FILE\s0"
.IX Subsection "MONITORING A FILE"
If you give a filename on the command line, innotop will not connect to \s-1ANY\s0
servers at all. It will watch the specified file for InnoDB status output and
@@ -553,7 +594,7 @@ commands are killing queries and stopping or starting slaves.
.PP
You can kill a connection, or in newer versions of MySQL kill a query but not a
connection, from \*(L"Q: Query List\*(R" and \*(L"T: InnoDB Transactions\*(R" modes.
-Press 'k' to issue a \s-1KILL\s0 command, or 'x' to issue a \s-1KILL\s0 \s-1QUERY\s0 command.
+Press 'k' to issue a \s-1KILL\s0 command, or 'x' to issue a \s-1KILL QUERY\s0 command.
innotop will prompt you for the server and/or connection \s-1ID\s0 to kill (innotop
does not prompt you if there is only one possible choice for any input).
innotop pre-selects the longest-running query, or the oldest connection.
@@ -561,17 +602,20 @@ Confirm the command with 'y'.
.PP
In \*(L"Slave Replication Status\*(R"\*(L" in \*(R"M: Master mode, you can start and stop slaves
with the 'a' and 'o' keys, respectively. You can send these commands to many
-slaves at once. innotop fills in a default command of \s-1START\s0 \s-1SLAVE\s0 or \s-1STOP\s0 \s-1SLAVE\s0
+slaves at once. innotop fills in a default command of \s-1START SLAVE\s0 or \s-1STOP SLAVE\s0
for you, but you can actually edit the command and send anything you wish, such
-as \s-1SET\s0 \s-1GLOBAL\s0 SQL_SLAVE_SKIP_COUNTER=1 to make the slave skip one binlog event
+as \s-1SET GLOBAL\s0 SQL_SLAVE_SKIP_COUNTER=1 to make the slave skip one binlog event
when it starts.
.PP
You can also ask innotop to calculate the earliest binlog in use by any slave
-and issue a \s-1PURGE\s0 \s-1MASTER\s0 \s-1LOGS\s0 on the master. Use the 'b' key for this. innotop
+and issue a \s-1PURGE MASTER LOGS\s0 on the master. Use the 'b' key for this. innotop
will prompt you for a master to run the command on, then prompt you for the
connection names of that master's slaves (there is no way for innotop to
determine this reliably itself). innotop will find the minimum binlog in use by
-these slave connections and suggest it as the argument to \s-1PURGE\s0 \s-1MASTER\s0 \s-1LOGS\s0.
+these slave connections and suggest it as the argument to \s-1PURGE MASTER LOGS.\s0
+.PP
+in \*(L"U: User Statistics\*(R" mode, you can use the 's' key to start and stop
+the collection of the statistics data for \s-1TABLE_STATISTICS\s0 and similar.
.SH "SERVER CONNECTIONS"
.IX Header "SERVER CONNECTIONS"
When you create a server connection using '@', innotop asks you for a series of
@@ -587,7 +631,7 @@ module for connecting to a server. It is usually of the form
.Sp
Since this \s-1DSN\s0 is passed to the DBD::mysql driver, you should read the driver's
documentation at \*(L"/search.cpan.org/dist/DBD\-mysql/lib/DBD/mysql.pm\*(R"\*(L" in \*(R"http: for
-the exact details on all the options you can pass the driver in the \s-1DSN\s0. You
+the exact details on all the options you can pass the driver in the \s-1DSN. \s0 You
can read more about \s-1DBI\s0 at , and especially at
.
.Sp
@@ -620,7 +664,7 @@ not encrypted in any way.
Once you finish answering these questions, you should be connected to a server.
But innotop isn't limited to monitoring a single server; you can define many
server connections and switch between them by pressing the '@' key. See
-\&\*(L"\s-1SWITCHING\s0 \s-1BETWEEN\s0 \s-1CONNECTIONS\s0\*(R".
+\&\*(L"\s-1SWITCHING BETWEEN CONNECTIONS\*(R"\s0.
.SH "SERVER GROUPS"
.IX Header "SERVER GROUPS"
If you have multiple MySQL instances, you can put them into named groups, such
@@ -640,7 +684,7 @@ want to use. This setting is per-mode, so you can monitor different connections
in each mode, and innotop remembers which connections you choose.
.PP
You can quickly switch to the 'next' connection in alphabetical order with the
-\&'n' key. If you're monitoring a server group (see \*(L"\s-1SERVER\s0 \s-1GROUPS\s0\*(R") this will
+\&'n' key. If you're monitoring a server group (see \*(L"\s-1SERVER GROUPS\*(R"\s0) this will
switch to the first connection.
.PP
You can also type many connection names, and innotop will fetch and display data
@@ -658,7 +702,7 @@ monitoring a large group or many connections, you may notice increased delay
between ticks.
.PP
When you monitor more than one connection, innotop's status bar changes. See
-\&\*(L"\s-1INNOTOP\s0 \s-1STATUS\s0\*(R".
+\&\*(L"\s-1INNOTOP STATUS\*(R"\s0.
.SH "ERROR HANDLING"
.IX Header "ERROR HANDLING"
Error handling is not that important when monitoring a single connection, but is
@@ -711,7 +755,7 @@ tick, so innotop may appear to hang.
.IP "\(bu" 4
innotop only displays the first table in each mode. This is so the output can
be easily processed with other command-line utilities such as awk and sed. To
-change which tables display in each mode, see \*(L"\s-1TABLES\s0\*(R". Since \*(L"Q: Query
+change which tables display in each mode, see \*(L"\s-1TABLES\*(R"\s0. Since \*(L"Q: Query
List\*(R" mode is so important, innotop automatically disables the \*(L"q_header\*(R"
table. This ensures you'll see the \*(L"processlist\*(R" table, even if you have
innotop configured to show the q_header table during interactive operation.
@@ -730,7 +774,7 @@ output.
innotop does not honor the \*(L"shorten\*(R" transformation, which normally shortens
some numbers to human-readable formats.
.IP "\(bu" 4
-innotop does not print a status line (see \*(L"\s-1INNOTOP\s0 \s-1STATUS\s0\*(R").
+innotop does not print a status line (see \*(L"\s-1INNOTOP STATUS\*(R"\s0).
.SH "CONFIGURING"
.IX Header "CONFIGURING"
Nearly everything about innotop is configurable. Most things are possible to
@@ -741,17 +785,17 @@ dialog. Press another key to select the type of data you want to edit:
.IP "S: Statement Sleep Times" 4
.IX Item "S: Statement Sleep Times"
Edits \s-1SQL\s0 statement sleep delays, which make innotop pause for the specified
-amount of time after executing a statement. See \*(L"\s-1SQL\s0 \s-1STATEMENTS\s0\*(R" for a
+amount of time after executing a statement. See \*(L"\s-1SQL STATEMENTS\*(R"\s0 for a
definition of each statement and what it does. By default innotop does not
delay after any statements.
.Sp
This feature is included so you can customize the side-effects caused by
monitoring your server. You may not see any effects, but some innotop users
have noticed that certain MySQL versions under very high load with InnoDB
-enabled take longer than usual to execute \s-1SHOW\s0 \s-1GLOBAL\s0 \s-1STATUS\s0. If innotop calls
-\&\s-1SHOW\s0 \s-1FULL\s0 \s-1PROCESSLIST\s0 immediately afterward, the processlist contains more
+enabled take longer than usual to execute \s-1SHOW GLOBAL STATUS. \s0 If innotop calls
+\&\s-1SHOW FULL PROCESSLIST\s0 immediately afterward, the processlist contains more
queries than the machine actually averages at any given moment. Configuring
-innotop to pause briefly after calling \s-1SHOW\s0 \s-1GLOBAL\s0 \s-1STATUS\s0 alleviates this
+innotop to pause briefly after calling \s-1SHOW GLOBAL STATUS\s0 alleviates this
effect.
.Sp
Sleep times are stored in the \*(L"stmt_sleep_times\*(R" section of the configuration
@@ -759,28 +803,28 @@ file. Fractional-second sleeps are supported, subject to your hardware's
limitations.
.IP "c: Edit Columns" 4
.IX Item "c: Edit Columns"
-Starts the table editor on one of the displayed tables. See \*(L"\s-1TABLE\s0 \s-1EDITOR\s0\*(R".
+Starts the table editor on one of the displayed tables. See \*(L"\s-1TABLE EDITOR\*(R"\s0.
An alternative way to start the table editor without entering the configuration
dialog is with the '^' key.
.IP "g: General Configuration" 4
.IX Item "g: General Configuration"
Starts the configuration editor to edit global and mode-specific configuration
-variables (see \*(L"\s-1MODES\s0\*(R"). innotop prompts you to choose a variable from among
+variables (see \*(L"\s-1MODES\*(R"\s0). innotop prompts you to choose a variable from among
the global and mode-specific ones depending on the current mode.
.IP "k: Row-Coloring Rules" 4
.IX Item "k: Row-Coloring Rules"
Starts the row-coloring rules editor on one of the displayed table(s). See
-\&\*(L"\s-1COLORS\s0\*(R" for details.
+\&\*(L"\s-1COLORS\*(R"\s0 for details.
.IP "p: Manage Plugins" 4
.IX Item "p: Manage Plugins"
-Starts the plugin configuration editor. See \*(L"\s-1PLUGINS\s0\*(R" for details.
+Starts the plugin configuration editor. See \*(L"\s-1PLUGINS\*(R"\s0 for details.
.IP "s: Server Groups" 4
.IX Item "s: Server Groups"
-Lets you create and edit server groups. See \*(L"\s-1SERVER\s0 \s-1GROUPS\s0\*(R".
+Lets you create and edit server groups. See \*(L"\s-1SERVER GROUPS\*(R"\s0.
.IP "t: Choose Displayed Tables" 4
.IX Item "t: Choose Displayed Tables"
-Lets you choose which tables to display in this mode. See \*(L"\s-1MODES\s0\*(R" and
-\&\*(L"\s-1TABLES\s0\*(R".
+Lets you choose which tables to display in this mode. See \*(L"\s-1MODES\*(R"\s0 and
+\&\*(L"\s-1TABLES\*(R"\s0.
.SH "CONFIGURATION FILE"
.IX Header "CONFIGURATION FILE"
innotop's default configuration file locations are \f(CW$HOME\fR/.innotop and
@@ -829,7 +873,7 @@ graphed; if s, values are like vmstat; if p, values are in a pivoted table.
.IP "S_set" 4
.IX Item "S_set"
Specifies which set of variables to display in \*(L"S: Variables & Status\*(R" mode.
-See \*(L"\s-1VARIABLE\s0 \s-1SETS\s0\*(R".
+See \*(L"\s-1VARIABLE SETS\*(R"\s0.
.IP "auto_wipe_dl" 4
.IX Item "auto_wipe_dl"
Instructs innotop to automatically wipe large deadlocks when it notices them.
@@ -866,7 +910,7 @@ crash.
.IP "debugfile" 4
.IX Item "debugfile"
A file to which innotop will write information when there is a crash. See
-\&\*(L"\s-1FILES\s0\*(R".
+\&\*(L"\s-1FILES\*(R"\s0.
.IP "display_table_captions" 4
.IX Item "display_table_captions"
innotop displays a table caption above most tables. This variable suppresses or
@@ -875,7 +919,7 @@ hide_caption property, which overrides this.
.IP "global" 4
.IX Item "global"
Whether to show \s-1GLOBAL\s0 variables and status. innotop only tries to do this on
-servers which support the \s-1GLOBAL\s0 option to \s-1SHOW\s0 \s-1VARIABLES\s0 and \s-1SHOW\s0 \s-1STATUS\s0. In
+servers which support the \s-1GLOBAL\s0 option to \s-1SHOW VARIABLES\s0 and \s-1SHOW STATUS. \s0 In
some MySQL versions, you need certain privileges to do this; if you don't have
them, innotop will not be able to fetch any variable and status data. This
configuration variable lets you run innotop and fetch what data you can even
@@ -904,7 +948,7 @@ This variable accepts fractions of a second.
.IP "mode" 4
.IX Item "mode"
The mode in which innotop should start. Allowable arguments are the same as the
-key presses that select a mode interactively. See \*(L"\s-1MODES\s0\*(R".
+key presses that select a mode interactively. See \*(L"\s-1MODES\*(R"\s0.
.IP "num_digits" 4
.IX Item "num_digits"
How many digits to show in fractional numbers and percents. This variable's
@@ -926,24 +970,28 @@ Specifies where plugins can be found. By default, innotop stores plugins in the
Whether the configuration file is readonly. This cannot be set interactively.
.IP "show_cxn_errors" 4
.IX Item "show_cxn_errors"
-Makes innotop print connection errors to \s-1STDOUT\s0. See \*(L"\s-1ERROR\s0 \s-1HANDLING\s0\*(R".
+Makes innotop print connection errors to \s-1STDOUT. \s0 See \*(L"\s-1ERROR HANDLING\*(R"\s0.
.IP "show_cxn_errors_in_tbl" 4
.IX Item "show_cxn_errors_in_tbl"
Makes innotop display connection errors as rows in the first table on screen.
-See \*(L"\s-1ERROR\s0 \s-1HANDLING\s0\*(R".
+See \*(L"\s-1ERROR HANDLING\*(R"\s0.
.IP "show_percent" 4
.IX Item "show_percent"
Adds a '%' character after the value returned by the \*(L"percent\*(R"
transformation.
.IP "show_statusbar" 4
.IX Item "show_statusbar"
-Controls whether to show the status bar in the display. See \*(L"\s-1INNOTOP\s0
-\&\s-1STATUS\s0\*(R".
+Controls whether to show the status bar in the display. See \*(L"\s-1INNOTOP
+STATUS\*(R"\s0.
.IP "skip_innodb" 4
.IX Item "skip_innodb"
-Disables fetching \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0, in case your server(s) do not have InnoDB
+Disables fetching \s-1SHOW INNODB STATUS,\s0 in case your server(s) do not have InnoDB
enabled and you don't want innotop to try to fetch it. This can also be useful
-when you don't have the \s-1SUPER\s0 privilege, required to run \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0.
+when you don't have the \s-1SUPER\s0 privilege, required to run \s-1SHOW INNODB STATUS.\s0
+.IP "spark" 4
+.IX Item "spark"
+Specifies how wide a spark chart is. There are two \s-1ASCII\s0 spark charts in A
+mode, showing \s-1QPS\s0 and User_threads_running.
.IP "status_inc" 4
.IX Item "status_inc"
Whether to show absolute or incremental values for status variables.
@@ -951,16 +999,20 @@ Incremental values are calculated as an offset from the last value innotop saw
for that variable. This is a global setting, but will probably become
mode-specific at some point. Right now it is honored a bit inconsistently; some
modes don't pay attention to it.
+.IP "timeformat" 4
+.IX Item "timeformat"
+The C\-style \fIstrftime()\fR\-compatible format for the timestamp line to be printed
+in \-n mode when \-t is set.
.RE
.RS 4
.RE
.IP "plugins" 4
.IX Item "plugins"
This section holds a list of package names of active plugins. If the plugin
-exists, innotop will activate it. See \*(L"\s-1PLUGINS\s0\*(R" for more information.
+exists, innotop will activate it. See \*(L"\s-1PLUGINS\*(R"\s0 for more information.
.IP "filters" 4
.IX Item "filters"
-This section holds user-defined filters (see \*(L"\s-1FILTERS\s0\*(R"). Each line is in the
+This section holds user-defined filters (see \*(L"\s-1FILTERS\*(R"\s0). Each line is in the
format filter_name=text='filter text' tbls='table list'.
.Sp
The filter text is the text of the subroutine's code. The table list is a list
@@ -973,7 +1025,7 @@ This section stores which filters are active on each table. Each line is in the
format table_name=filter_list.
.IP "tbl_meta" 4
.IX Item "tbl_meta"
-This section stores user-defined or user-customized columns (see \*(L"\s-1COLUMNS\s0\*(R").
+This section stores user-defined or user-customized columns (see \*(L"\s-1COLUMNS\*(R"\s0).
Each line is in the format col_name=properties, where the properties are a
name=quoted\-value list.
.IP "connections" 4
@@ -982,8 +1034,8 @@ This section holds the server connections you have defined. Each line is in
the format name=properties, where the properties are a name=value list. The
properties are self-explanatory, and the only one that is treated specially is
\&'pass' which is only present if 'savepass' is set. This section of the
-configuration file will be skipped if any \s-1DSN\s0, username, or password
-command-line options are used. See \*(L"\s-1SERVER\s0 \s-1CONNECTIONS\s0\*(R".
+configuration file will be skipped if any \s-1DSN,\s0 username, or password
+command-line options are used. See \*(L"\s-1SERVER CONNECTIONS\*(R"\s0.
.IP "active_connections" 4
.IX Item "active_connections"
This section holds a list of which connections are active in each mode. Each
@@ -991,7 +1043,7 @@ line is in the format mode_name=connection_list.
.IP "server_groups" 4
.IX Item "server_groups"
This section holds server groups. Each line is in the format
-name=connection_list. See \*(L"\s-1SERVER\s0 \s-1GROUPS\s0\*(R".
+name=connection_list. See \*(L"\s-1SERVER GROUPS\*(R"\s0.
.IP "active_server_groups" 4
.IX Item "active_server_groups"
This section holds a list of which server group is active in each mode. Each
@@ -1004,24 +1056,24 @@ name=value.
.IP "active_columns" 4
.IX Item "active_columns"
This section holds table column lists. Each line is in the format
-tbl_name=column_list. See \*(L"\s-1COLUMNS\s0\*(R".
+tbl_name=column_list. See \*(L"\s-1COLUMNS\*(R"\s0.
.IP "sort_cols" 4
.IX Item "sort_cols"
This section holds the sort definition. Each line is in the format
tbl_name=column_list. If a column is prefixed with '\-', that column sorts
-descending. See \*(L"\s-1SORTING\s0\*(R".
+descending. See \*(L"\s-1SORTING\*(R"\s0.
.IP "visible_tables" 4
.IX Item "visible_tables"
This section defines which tables are visible in each mode. Each line is in the
-format mode_name=table_list. See \*(L"\s-1TABLES\s0\*(R".
+format mode_name=table_list. See \*(L"\s-1TABLES\*(R"\s0.
.IP "varsets" 4
.IX Item "varsets"
This section defines variable sets for use in \*(L"S: Status & Variables\*(R" mode.
-Each line is in the format name=variable_list. See \*(L"\s-1VARIABLE\s0 \s-1SETS\s0\*(R".
+Each line is in the format name=variable_list. See \*(L"\s-1VARIABLE SETS\*(R"\s0.
.IP "colors" 4
.IX Item "colors"
This section defines colorization rules. Each line is in the format
-tbl_name=property_list. See \*(L"\s-1COLORS\s0\*(R".
+tbl_name=property_list. See \*(L"\s-1COLORS\*(R"\s0.
.IP "stmt_sleep_times" 4
.IX Item "stmt_sleep_times"
This section contains statement sleep times. Each line is in the format
@@ -1029,7 +1081,7 @@ statement_name=sleep_time. See \*(L"S: Statement Sleep Times\*(R".
.IP "group_by" 4
.IX Item "group_by"
This section contains column lists for table group_by expressions. Each line is
-in the format tbl_name=column_list. See \*(L"\s-1GROUPING\s0\*(R".
+in the format tbl_name=column_list. See \*(L"\s-1GROUPING\*(R"\s0.
.SH "CUSTOMIZING"
.IX Header "CUSTOMIZING"
You can customize innotop a great deal. For example, you can:
@@ -1065,10 +1117,10 @@ instructions to innotop. The meta-data includes the caption, a list of columns
the user has customized, a list of columns, a list of visible columns, a list of
filters, color rules, a sort-column list, sort direction, and some information
about the table's data sources. Most of this is customizable via the table
-editor (see \*(L"\s-1TABLE\s0 \s-1EDITOR\s0\*(R").
+editor (see \*(L"\s-1TABLE EDITOR\*(R"\s0).
.PP
-You can choose which tables to show by pressing the '$' key. See \*(L"\s-1MODES\s0\*(R" and
-\&\*(L"\s-1TABLES\s0\*(R".
+You can choose which tables to show by pressing the '$' key. See \*(L"\s-1MODES\*(R"\s0 and
+\&\*(L"\s-1TABLES\*(R"\s0.
.PP
The table life-cycle is as follows:
.IP "\(bu" 4
@@ -1081,21 +1133,21 @@ For each element in the data source, innotop extracts values from the source and
creates a row. This row is another hash, which later steps will refer to as
\&\f(CW$set\fR. The values innotop extracts are determined by the table's columns. Each
column has an extraction subroutine, compiled from an expression (see
-\&\*(L"\s-1EXPRESSIONS\s0\*(R"). The resulting row is a hash whose keys are named the same as
+\&\*(L"\s-1EXPRESSIONS\*(R"\s0). The resulting row is a hash whose keys are named the same as
the column name.
.IP "\(bu" 4
innotop filters the rows, removing those that don't need to be displayed. See
-\&\*(L"\s-1FILTERS\s0\*(R".
+\&\*(L"\s-1FILTERS\*(R"\s0.
.IP "\(bu" 4
-innotop sorts the rows. See \*(L"\s-1SORTING\s0\*(R".
+innotop sorts the rows. See \*(L"\s-1SORTING\*(R"\s0.
.IP "\(bu" 4
-innotop groups the rows together, if specified. See \*(L"\s-1GROUPING\s0\*(R".
+innotop groups the rows together, if specified. See \*(L"\s-1GROUPING\*(R"\s0.
.IP "\(bu" 4
-innotop colorizes the rows. See \*(L"\s-1COLORS\s0\*(R".
+innotop colorizes the rows. See \*(L"\s-1COLORS\*(R"\s0.
.IP "\(bu" 4
-innotop transforms the column values in each row. See \*(L"\s-1TRANSFORMATIONS\s0\*(R".
+innotop transforms the column values in each row. See \*(L"\s-1TRANSFORMATIONS\*(R"\s0.
.IP "\(bu" 4
-innotop optionally pivots the rows (see \*(L"\s-1PIVOTING\s0\*(R"), then filters and sorts
+innotop optionally pivots the rows (see \*(L"\s-1PIVOTING\*(R"\s0), then filters and sorts
them.
.IP "\(bu" 4
innotop formats and justifies the rows as a table. During this step, innotop
@@ -1108,7 +1160,7 @@ The lifecycle is slightly different if the table is pivoted, as noted above. To
clarify, if the table is pivoted, the process is extract, group, transform,
pivot, filter, sort, create. If it's not pivoted, the process is extract,
filter, sort, group, color, transform, create. This slightly convoluted process
-doesn't map all that well to \s-1SQL\s0, but pivoting complicates things pretty
+doesn't map all that well to \s-1SQL,\s0 but pivoting complicates things pretty
thoroughly. Roughly speaking, filtering and sorting happen as late as needed to
effect the final result as you might expect, but as early as possible for
efficiency.
@@ -1117,99 +1169,119 @@ Each built-in table is described below:
.IP "adaptive_hash_index" 4
.IX Item "adaptive_hash_index"
Displays data about InnoDB's adaptive hash index. Data source:
-\&\*(L"\s-1STATUS_VARIABLES\s0\*(R".
+\&\*(L"\s-1STATUS_VARIABLES\*(R"\s0.
.IP "buffer_pool" 4
.IX Item "buffer_pool"
-Displays data about InnoDB's buffer pool. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+Displays data about InnoDB's buffer pool. Data source: \*(L"\s-1STATUS_VARIABLES\*(R"\s0.
.IP "cmd_summary" 4
.IX Item "cmd_summary"
-Displays weighted status variables. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+Displays weighted status variables. Data source: \*(L"\s-1STATUS_VARIABLES\*(R"\s0.
.IP "deadlock_locks" 4
.IX Item "deadlock_locks"
Shows which locks were held and waited for by the last detected deadlock. Data
-source: \*(L"\s-1DEADLOCK_LOCKS\s0\*(R".
+source: \*(L"\s-1DEADLOCK_LOCKS\*(R"\s0.
.IP "deadlock_transactions" 4
.IX Item "deadlock_transactions"
Shows transactions involved in the last detected deadlock. Data source:
-\&\*(L"\s-1DEADLOCK_TRANSACTIONS\s0\*(R".
+\&\*(L"\s-1DEADLOCK_TRANSACTIONS\*(R"\s0.
.IP "explain" 4
.IX Item "explain"
-Shows the output of \s-1EXPLAIN\s0. Data source: \*(L"\s-1EXPLAIN\s0\*(R".
+Shows the output of \s-1EXPLAIN. \s0 Data source: \*(L"\s-1EXPLAIN\*(R"\s0.
.IP "file_io_misc" 4
.IX Item "file_io_misc"
Displays data about InnoDB's file and I/O operations. Data source:
-\&\*(L"\s-1STATUS_VARIABLES\s0\*(R".
+\&\*(L"\s-1STATUS_VARIABLES\*(R"\s0.
.IP "fk_error" 4
.IX Item "fk_error"
Displays various data about InnoDB's last foreign key error. Data source:
-\&\*(L"\s-1STATUS_VARIABLES\s0\*(R".
+\&\*(L"\s-1STATUS_VARIABLES\*(R"\s0.
+.IP "health_dashboard" 4
+.IX Item "health_dashboard"
+Displays an overall summary of servers, one server per line, for monitoring.
+Data source: \*(L"\s-1STATUS_VARIABLES\*(R"\s0, \*(L"\s-1MASTER_SLAVE\*(R"\s0, \*(L"\s-1PROCESSLIST_STATS\*(R"\s0.
+.IP "index_statistics" 4
+.IX Item "index_statistics"
+Displays data from the \s-1INDEX_STATISTICS\s0 table in Percona-enhanced servers.
+.IP "index_table_statistics" 4
+.IX Item "index_table_statistics"
+Displays data from the \s-1INDEX_STATISTICS\s0 and \s-1TABLE_STATISTICS\s0 tables in
+Percona-enhanced servers. It joins the two together, grouped by the database
+and table name. It is the default view in \*(L"U: User Statistics\*(R" mode,
+and makes it easy to see what tables are hot, how many rows are read from indexes,
+how many changes are made, and how many changes are made to indexes.
+.IP "innodb_blocked_blocker" 4
+.IX Item "innodb_blocked_blocker"
+Displays InnoDB locks and lock waits. Data source: \*(L"\s-1INNODB_BLOCKED_BLOCKER\*(R"\s0.
.IP "innodb_locks" 4
.IX Item "innodb_locks"
-Displays InnoDB locks. Data source: \*(L"\s-1INNODB_LOCKS\s0\*(R".
+Displays InnoDB locks. Data source: \*(L"\s-1INNODB_LOCKS\*(R"\s0.
.IP "innodb_transactions" 4
.IX Item "innodb_transactions"
Displays data about InnoDB's current transactions. Data source:
-\&\*(L"\s-1INNODB_TRANSACTIONS\s0\*(R".
+\&\*(L"\s-1INNODB_TRANSACTIONS\*(R"\s0.
.IP "insert_buffers" 4
.IX Item "insert_buffers"
-Displays data about InnoDB's insert buffer. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+Displays data about InnoDB's insert buffer. Data source: \*(L"\s-1STATUS_VARIABLES\*(R"\s0.
.IP "io_threads" 4
.IX Item "io_threads"
-Displays data about InnoDB's I/O threads. Data source: \*(L"\s-1IO_THREADS\s0\*(R".
+Displays data about InnoDB's I/O threads. Data source: \*(L"\s-1IO_THREADS\*(R"\s0.
.IP "log_statistics" 4
.IX Item "log_statistics"
-Displays data about InnoDB's logging system. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+Displays data about InnoDB's logging system. Data source: \*(L"\s-1STATUS_VARIABLES\*(R"\s0.
.IP "master_status" 4
.IX Item "master_status"
-Displays replication master status. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+Displays replication master status. Data source: \*(L"\s-1STATUS_VARIABLES\*(R"\s0.
.IP "open_tables" 4
.IX Item "open_tables"
-Displays open tables. Data source: \*(L"\s-1OPEN_TABLES\s0\*(R".
+Displays open tables. Data source: \*(L"\s-1OPEN_TABLES\*(R"\s0.
.IP "page_statistics" 4
.IX Item "page_statistics"
-Displays InnoDB page statistics. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+Displays InnoDB page statistics. Data source: \*(L"\s-1STATUS_VARIABLES\*(R"\s0.
.IP "pending_io" 4
.IX Item "pending_io"
-Displays InnoDB pending I/O operations. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+Displays InnoDB pending I/O operations. Data source: \*(L"\s-1STATUS_VARIABLES\*(R"\s0.
.IP "processlist" 4
.IX Item "processlist"
Displays current MySQL processes (threads/connections). Data source:
-\&\*(L"\s-1PROCESSLIST\s0\*(R".
+\&\*(L"\s-1PROCESSLIST\*(R"\s0.
.IP "q_header" 4
.IX Item "q_header"
-Displays various status values. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+Displays various status values. Data source: \*(L"\s-1STATUS_VARIABLES\*(R"\s0.
.IP "row_operation_misc" 4
.IX Item "row_operation_misc"
Displays data about InnoDB's row operations. Data source:
-\&\*(L"\s-1STATUS_VARIABLES\s0\*(R".
+\&\*(L"\s-1STATUS_VARIABLES\*(R"\s0.
.IP "row_operations" 4
.IX Item "row_operations"
Displays data about InnoDB's row operations. Data source:
-\&\*(L"\s-1STATUS_VARIABLES\s0\*(R".
+\&\*(L"\s-1STATUS_VARIABLES\*(R"\s0.
.IP "semaphores" 4
.IX Item "semaphores"
Displays data about InnoDB's semaphores and mutexes. Data source:
-\&\*(L"\s-1STATUS_VARIABLES\s0\*(R".
+\&\*(L"\s-1STATUS_VARIABLES\*(R"\s0.
.IP "slave_io_status" 4
.IX Item "slave_io_status"
Displays data about the slave I/O thread. Data source:
-\&\*(L"\s-1STATUS_VARIABLES\s0\*(R".
+\&\*(L"\s-1STATUS_VARIABLES\*(R"\s0.
.IP "slave_sql_status" 4
.IX Item "slave_sql_status"
-Displays data about the slave \s-1SQL\s0 thread. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+Displays data about the slave \s-1SQL\s0 thread. Data source: \*(L"\s-1STATUS_VARIABLES\*(R"\s0.
+.IP "table_statistics" 4
+.IX Item "table_statistics"
+Displays data from the \s-1TABLE_STATISTICS\s0 table in Percona-enhanced servers.
.IP "t_header" 4
.IX Item "t_header"
-Displays various InnoDB status values. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+Displays various InnoDB status values. Data source: \*(L"\s-1STATUS_VARIABLES\*(R"\s0.
.IP "var_status" 4
.IX Item "var_status"
-Displays user-configurable data. Data source: \*(L"\s-1STATUS_VARIABLES\s0\*(R".
+Displays user-configurable data. Data source: \*(L"\s-1STATUS_VARIABLES\*(R"\s0.
.IP "wait_array" 4
.IX Item "wait_array"
-Displays data about InnoDB's \s-1OS\s0 wait array. Data source: \*(L"\s-1OS_WAIT_ARRAY\s0\*(R".
+Displays data about InnoDB's \s-1OS\s0 wait array. Data source: \*(L"\s-1OS_WAIT_ARRAY\*(R"\s0.
.SS "\s-1COLUMNS\s0"
.IX Subsection "COLUMNS"
Columns belong to tables. You can choose a table's columns by pressing the '^'
-key, which starts the \*(L"\s-1TABLE\s0 \s-1EDITOR\s0\*(R" and lets you choose and edit columns.
+key, which starts the \*(L"\s-1TABLE EDITOR\*(R"\s0 and lets you choose and edit columns.
Pressing 'e' from within the table editor lets you edit the column's properties:
.IP "\(bu" 4
hdr: a column header. This appears in the first row of the table.
@@ -1226,28 +1298,30 @@ label: a small note about the column, which appears in dialogs that help the
user choose columns.
.IP "\(bu" 4
src: an expression that innotop uses to extract the column's data from its
-source (see \*(L"\s-1DATA\s0 \s-1SOURCES\s0\*(R"). See \*(L"\s-1EXPRESSIONS\s0\*(R" for more on expressions.
+source (see \*(L"\s-1DATA SOURCES\*(R"\s0). See \*(L"\s-1EXPRESSIONS\*(R"\s0 for more on expressions.
.IP "\(bu" 4
minw: specifies a minimum display width. This helps stabilize the display,
which makes it easier to read if the data is changing frequently.
.IP "\(bu" 4
maxw: similar to minw.
.IP "\(bu" 4
-trans: a list of column transformations. See \*(L"\s-1TRANSFORMATIONS\s0\*(R".
+trans: a list of column transformations. See \*(L"\s-1TRANSFORMATIONS\*(R"\s0.
.IP "\(bu" 4
-agg: an aggregate function. See \*(L"\s-1GROUPING\s0\*(R". The default is \*(L"first\*(R".
+agg: an aggregate function. See \*(L"\s-1GROUPING\*(R"\s0. The default is \*(L"first\*(R".
.IP "\(bu" 4
aggonly: controls whether the column only shows when grouping is enabled on the
-table (see \*(L"\s-1GROUPING\s0\*(R"). By default, this is disabled. This means columns
+table (see \*(L"\s-1GROUPING\*(R"\s0). By default, this is disabled. This means columns
will always be shown by default, whether grouping is enabled or not. If a
column's aggonly is set true, the column will appear when you toggle grouping on
the table. Several columns are set this way, such as the count column on
\&\*(L"processlist\*(R" and \*(L"innodb_transactions\*(R", so you don't see a count when the
grouping isn't enabled, but you do when it is.
+.IP "\(bu" 4
+agghide: the reverse of aggonly. The column is hidden when grouping is enabled.
.SS "\s-1FILTERS\s0"
.IX Subsection "FILTERS"
Filters remove rows from the display. They behave much like a \s-1WHERE\s0 clause in
-\&\s-1SQL\s0. innotop has several built-in filters, which remove irrelevant information
+\&\s-1SQL. \s0 innotop has several built-in filters, which remove irrelevant information
like inactive queries, but you can define your own as well. innotop also lets
you create quick-filters, which do not get saved to the configuration file, and
are just an easy way to quickly view only some rows.
@@ -1297,11 +1371,30 @@ persist when you restart innotop. To create a quick-filter, press the '/' key.
innotop will prompt you for the column name and filter text. Again, you can use
auto-completion on column names. The filter text can be just the text you want
to \*(L"search for.\*(R" For example, to filter the \*(L"processlist\*(R" table on queries
-that refer to the products table, type '/' and then 'info product'.
+that refer to the products table, type '/' and then 'info product'. Internally,
+the filter is compiled into a subroutine like this:
+.PP
+.Vb 4
+\& sub filter {
+\& my ( $set ) = @_;
+\& $set\->{info} =~ m/product/;
+\& }
+.Ve
.PP
The filter text can actually be any Perl regular expression, but of course a
literal string like 'product' works fine as a regular expression.
.PP
+What if you want the filter to discard matching rows, rather than showing
+matching rows? If you're familiar with Perl regular expressions, you might
+guess how to do this. You have to use a zero-width negative lookahead
+assertion. If you don't know what that means, don't worry. Let's filter out
+all rows where the command is Gandalf. Type the following:
+.PP
+.Vb 2
+\& 1. /
+\& 2. cmd ^(?!Gandalf)
+.Ve
+.PP
Behind the scenes innotop compiles the quick-filter into a specially tagged
filter that is otherwise like any other filter. It just isn't saved to the
configuration file.
@@ -1314,7 +1407,7 @@ innotop has sensible built-in defaults to sort the most important rows to the
top of the table. Like anything else in innotop, you can customize how any
table is sorted.
.PP
-To start the sort dialog, start the \*(L"\s-1TABLE\s0 \s-1EDITOR\s0\*(R" with the '^' key, choose a
+To start the sort dialog, start the \*(L"\s-1TABLE EDITOR\*(R"\s0 with the '^' key, choose a
table if necessary, and press the 's' key. You'll see a list of columns you can
use in the sort expression and the current sort expression, if any. Enter a
list of columns by which you want to sort and press Enter. If you want to
@@ -1328,9 +1421,9 @@ sort direction. Press '?' as usual to see which keys are mapped in any mode.
.SS "\s-1GROUPING\s0"
.IX Subsection "GROUPING"
innotop can group, or aggregate, rows together (the terms are used
-interchangeably). This is quite similar to an \s-1SQL\s0 \s-1GROUP\s0 \s-1BY\s0 clause. You can
+interchangeably). This is quite similar to an \s-1SQL GROUP BY\s0 clause. You can
specify to group on certain columns, or if you don't specify any, the entire set
-of rows is treated as one group. This is quite like \s-1SQL\s0 so far, but unlike \s-1SQL\s0,
+of rows is treated as one group. This is quite like \s-1SQL\s0 so far, but unlike \s-1SQL,\s0
you can also select un-grouped columns. innotop actually aggregates every
column. If you don't explicitly specify a grouping function, the default is
\&'first'. This is basically a convenience so you don't have to specify an
@@ -1391,8 +1484,8 @@ That's actually quite a worrisome picture. You've got a lot of idle connections
(Sleep), and some connections executing queries (Query and Sending Data).
That's okay, but you also have a lot in Statistics status, collectively spending
over a minute. That means the query optimizer is having a really hard time
-optimizing your statements. Something is wrong; it should normally take
-milliseconds to optimize queries. You might not have seen this pattern if you
+generating execution plans for your statements. Something is wrong; it should
+normally take milliseconds to plan queries. You might not have seen this pattern if you
didn't look at your connections in aggregate. (This is a made-up example, but
it can happen in real life).
.SS "\s-1PIVOTING\s0"
@@ -1467,7 +1560,7 @@ quoted something.
.IX Subsection "EXPRESSIONS"
Expressions are at the core of how innotop works, and are what enables you to
extend innotop as you wish. Recall the table lifecycle explained in
-\&\*(L"\s-1TABLES\s0\*(R". Expressions are used in the earliest step, where it extracts
+\&\*(L"\s-1TABLES\*(R"\s0. Expressions are used in the earliest step, where it extracts
values from a data source to form rows.
.PP
It does this by calling a subroutine for each column, passing it the source data
@@ -1500,7 +1593,7 @@ subroutine, like this:
.PP
Here's a concrete example, taken from the header table \*(L"q_header\*(R" in \*(L"Q:
Query List\*(R" mode. This expression calculates the qps, or Queries Per Second,
-column's values, from the values returned by \s-1SHOW\s0 \s-1STATUS:\s0
+column's values, from the values returned by \s-1SHOW STATUS:\s0
.PP
.Vb 1
\& Questions/Uptime_hires
@@ -1532,11 +1625,17 @@ are defined:
.IP "commify" 4
.IX Item "commify"
Adds commas to large numbers every three decimal places.
+.IP "distill" 4
+.IX Item "distill"
+Distills \s-1SQL\s0 into verb-noun-noun format for quick comprehension.
.IP "dulint_to_int" 4
.IX Item "dulint_to_int"
Accepts two unsigned integers and converts them into a single longlong. This is
useful for certain operations with InnoDB, which uses two integers as
transaction identifiers, for example.
+.IP "fuzzy_time" 4
+.IX Item "fuzzy_time"
+Converts a number of seconds into a friendly, readable value like \*(L"1h35m\*(R".
.IP "no_ctrl_char" 4
.IX Item "no_ctrl_char"
Removes quoted control characters from the value. This is affected by the
@@ -1561,7 +1660,7 @@ Formats numbers with \*(L"num_digits\*(R" number of digits after the decimal poi
.IX Item "shorten"
Formats a number as a unit of 1024 (k/M/G/T) and with \*(L"num_digits\*(R" number of
digits after the decimal point.
-.SS "\s-1TABLE\s0 \s-1EDITOR\s0"
+.SS "\s-1TABLE EDITOR\s0"
.IX Subsection "TABLE EDITOR"
The innotop table editor lets you customize tables with keystrokes. You start
the table editor with the '^' key. If there's more than one table on the
@@ -1579,7 +1678,7 @@ show you something like this:
\& pages_modified Dirty Pages Pages modified (dirty IB_bp_pages_m
\& buf_pool_hit_rate Hit Rate Buffer pool hit rate IB_bp_buf_poo
\& total_mem_alloc Memory Total memory allocate IB_bp_total_m
-\& add_pool_alloc Add\*(Aql Pool Additional pool alloca IB_bp_add_poo
+\& add_pool_alloc Add\*(Aql Pool Additonal pool alloca IB_bp_add_poo
.Ve
.PP
The first line shows which table you're editing, and reminds you again to press
@@ -1590,7 +1689,7 @@ editor, color rule editor, and more.
.PP
Each row in the display shows a single column in the table you're editing, along
with a couple of its properties such as its header and source expression (see
-\&\*(L"\s-1EXPRESSIONS\s0\*(R").
+\&\*(L"\s-1EXPRESSIONS\*(R"\s0).
.PP
The key mappings are Vim-style, as in many other places. Pressing 'j' and 'k'
moves the highlight up or down. You can then (d)elete or (e)dit the highlighted
@@ -1615,9 +1714,9 @@ the table header. This can have spaces and funny characters, but be careful not
to make it too wide and waste space on-screen.
.IP "\(bu" 4
The column's data source: this is an expression that determines what data from
-the source (see \*(L"\s-1TABLES\s0\*(R") innotop will put into the column. This can just be
+the source (see \*(L"\s-1TABLES\*(R"\s0) innotop will put into the column. This can just be
the name of an item in the source, or it can be a more complex expression, as
-described in \*(L"\s-1EXPRESSIONS\s0\*(R".
+described in \*(L"\s-1EXPRESSIONS\*(R"\s0.
.PP
Once you've entered the required data, your table has a new column. There is no
difference between this column and the built-in ones; it can have all the same
@@ -1645,10 +1744,10 @@ what variables you want to monitor. Behind the scenes they are compiled to a
list of expressions, and then into a column list so they can be treated just
like columns in any other table, in terms of data extraction and
transformations. However, you're protected from the tedious details by a syntax
-that ought to feel very natural to you: a \s-1SQL\s0 \s-1SELECT\s0 list.
+that ought to feel very natural to you: a \s-1SQL SELECT\s0 list.
.PP
The data source for variable sets, and indeed the entire S mode, is the
-combination of \s-1SHOW\s0 \s-1STATUS\s0, \s-1SHOW\s0 \s-1VARIABLES\s0, and \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0. Imagine
+combination of \s-1SHOW STATUS, SHOW VARIABLES,\s0 and \s-1SHOW INNODB STATUS. \s0 Imagine
that you had a huge table with one column per variable returned from those
statements. That's the data source for variable sets. You can now query this
data source just like you'd expect. For example:
@@ -1669,7 +1768,7 @@ start for creating your own. Press 'e' to edit the current variable set, or
just to see how it's defined. To create a new one, just press 'c' and type its
name.
.PP
-You may want to use some of the functions listed in \*(L"\s-1TRANSFORMATIONS\s0\*(R" to help
+You may want to use some of the functions listed in \*(L"\s-1TRANSFORMATIONS\*(R"\s0 to help
format the results. In particular, \*(L"set_precision\*(R" is often useful to limit
the number of digits you see. Extending the above example, here's how:
.PP
@@ -1694,9 +1793,9 @@ or modify its existing functionality, and add new functionality. innotop's
plugin functionality is event-based: plugins register themselves to be called
when events happen. They then have a chance to influence the event.
.PP
-An innotop plugin is a Perl module placed in innotop's \*(L"plugin_dir\*(R"
+An innotop plugin is a Perl module (.pm) file placed in innotop's \*(L"plugin_dir\*(R"
directory. On \s-1UNIX\s0 systems, you can place a symbolic link to the module instead
-of putting the actual file there. innotop automatically discovers the file. If
+of putting the actual file there. innotop automatically discovers files named \f(CW\*(C`*.pm\*(C'\fR. If
there is a corresponding entry in the \*(L"plugins\*(R" configuration file section,
innotop loads and activates the plugin.
.PP
@@ -1708,7 +1807,7 @@ file and determine the package name and description.
innotop inspects the plugin module's source to determine the Perl package name.
It looks for a line of the form \*(L"package Foo;\*(R" and if found, considers the
plugin's package name to be Foo. Of course the package name can be a valid Perl
-package name, with double semicolons and so on.
+package name such as Foo::Bar, with double colons (::) and so on.
.PP
It also looks for a description in the source code, to make the plugin editor
more human-friendly. The description is a comment line of the form \*(L"#
@@ -1758,7 +1857,7 @@ for later use. The variables are defined in the innotop variable
A hashref of key mappings. These are innotop's global hot-keys.
.IP "agg_funcs" 4
.IX Item "agg_funcs"
-A hashref of functions that can be used for grouping. See \*(L"\s-1GROUPING\s0\*(R".
+A hashref of functions that can be used for grouping. See \*(L"\s-1GROUPING\*(R"\s0.
.IP "config" 4
.IX Item "config"
The global configuration hash.
@@ -1772,23 +1871,23 @@ A hashref of innotop's database connections. These are actual \s-1DBI\s0 connec
objects.
.IP "filters" 4
.IX Item "filters"
-A hashref of filters applied to table rows. See \*(L"\s-1FILTERS\s0\*(R" for more.
+A hashref of filters applied to table rows. See \*(L"\s-1FILTERS\*(R"\s0 for more.
.IP "modes" 4
.IX Item "modes"
-A hashref of modes. See \*(L"\s-1MODES\s0\*(R" for more.
+A hashref of modes. See \*(L"\s-1MODES\*(R"\s0 for more.
.IP "server_groups" 4
.IX Item "server_groups"
-A hashref of server groups. See \*(L"\s-1SERVER\s0 \s-1GROUPS\s0\*(R".
+A hashref of server groups. See \*(L"\s-1SERVER GROUPS\*(R"\s0.
.IP "tbl_meta" 4
.IX Item "tbl_meta"
A hashref of innotop's table meta-data, with one entry per table (see
-\&\*(L"\s-1TABLES\s0\*(R" for more information).
+\&\*(L"\s-1TABLES\*(R"\s0 for more information).
.IP "trans_funcs" 4
.IX Item "trans_funcs"
-A hashref of transformation functions. See \*(L"\s-1TRANSFORMATIONS\s0\*(R".
+A hashref of transformation functions. See \*(L"\s-1TRANSFORMATIONS\*(R"\s0.
.IP "var_sets" 4
.IX Item "var_sets"
-A hashref of variable sets. See \*(L"\s-1VARIABLE\s0 \s-1SETS\s0\*(R".
+A hashref of variable sets. See \*(L"\s-1VARIABLE SETS\*(R"\s0.
.SS "Plugin Events"
.IX Subsection "Plugin Events"
Each event is defined somewhere in the innotop source code. When innotop runs
@@ -1818,7 +1917,9 @@ This event occurs inside the subroutine that prints the lines to the screen.
.IX Subsection "Simple Plugin Example"
The easiest way to explain the plugin functionality is probably with a simple
example. The following module adds a column to the beginning of every table and
-sets its value to 1.
+sets its value to 1. (If you copy and paste this example code, be sure to remove
+the first space from each line; lines such as '# description' must not start with
+whitespace).
.PP
.Vb 2
\& use strict;
@@ -1887,12 +1988,13 @@ inactive. Exit the editor and restart innotop for the changes to take effect.
innotop uses a limited set of \s-1SQL\s0 statements to retrieve data from MySQL for
display. The statements are customized depending on the server version against
which they are executed; for example, on MySQL 5 and newer, \s-1INNODB_STATUS\s0
-executes \*(L"\s-1SHOW\s0 \s-1ENGINE\s0 \s-1INNODB\s0 \s-1STATUS\s0\*(R", while on earlier versions it executes
-\&\*(L"\s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0\*(R". The statements are as follows:
+executes \*(L"\s-1SHOW ENGINE INNODB STATUS\*(R",\s0 while on earlier versions it executes
+\&\*(L"\s-1SHOW INNODB STATUS\*(R". \s0 The statements are as follows:
.PP
-.Vb 12
+.Vb 10
\& Statement SQL executed
\& =================== ===============================
+\& INDEX_STATISTICS SELECT * FROM INFORMATION_SCHEMA.INDEX_STATISTICS
\& INNODB_STATUS SHOW [ENGINE] INNODB STATUS
\& KILL_CONNECTION KILL
\& KILL_QUERY KILL QUERY
@@ -1903,13 +2005,14 @@ executes \*(L"\s-1SHOW\s0 \s-1ENGINE\s0 \s-1INNODB\s0 \s-1STATUS\s0\*(R", while
\& SHOW_SLAVE_STATUS SHOW SLAVE STATUS
\& SHOW_STATUS SHOW [GLOBAL] STATUS
\& SHOW_VARIABLES SHOW [GLOBAL] VARIABLES
+\& TABLE_STATISTICS SELECT * FROM INFORMATION_SCHEMA.TABLE_STATISTICS
.Ve
.SH "DATA SOURCES"
.IX Header "DATA SOURCES"
-Each time innotop extracts values to create a table (see \*(L"\s-1EXPRESSIONS\s0\*(R" and
-\&\*(L"\s-1TABLES\s0\*(R"), it does so from a particular data source. Largely because of the
-complex data extracted from \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0, this is slightly messy. \s-1SHOW\s0
-\&\s-1INNODB\s0 \s-1STATUS\s0 contains a mixture of single values and repeated values that form
+Each time innotop extracts values to create a table (see \*(L"\s-1EXPRESSIONS\*(R"\s0 and
+\&\*(L"\s-1TABLES\*(R"\s0), it does so from a particular data source. Largely because of the
+complex data extracted from \s-1SHOW INNODB STATUS,\s0 this is slightly messy. \s-1SHOW
+INNODB STATUS\s0 contains a mixture of single values and repeated values that form
nested data sets.
.PP
Whenever innotop fetches data from MySQL, it adds two extra bits to each set:
@@ -1921,41 +2024,53 @@ Here are the kinds of data sources from which data is extracted:
.IP "\s-1STATUS_VARIABLES\s0" 4
.IX Item "STATUS_VARIABLES"
This is the broadest category, into which the most kinds of data fall. It
-begins with the combination of \s-1SHOW\s0 \s-1STATUS\s0 and \s-1SHOW\s0 \s-1VARIABLES\s0, but other sources
-may be included as needed, for example, \s-1SHOW\s0 \s-1MASTER\s0 \s-1STATUS\s0 and \s-1SHOW\s0 \s-1SLAVE\s0
-\&\s-1STATUS\s0, as well as many of the non-repeated values from \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0.
+begins with the combination of \s-1SHOW STATUS\s0 and \s-1SHOW VARIABLES,\s0 but other sources
+may be included as needed, for example, \s-1SHOW MASTER STATUS\s0 and \s-1SHOW SLAVE
+STATUS,\s0 as well as many of the non-repeated values from \s-1SHOW INNODB STATUS.\s0
.IP "\s-1DEADLOCK_LOCKS\s0" 4
.IX Item "DEADLOCK_LOCKS"
-This data is extracted from the transaction list in the \s-1LATEST\s0 \s-1DETECTED\s0 \s-1DEADLOCK\s0
-section of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0. It is nested two levels deep: transactions, then
+This data is extracted from the transaction list in the \s-1LATEST DETECTED DEADLOCK\s0
+section of \s-1SHOW INNODB STATUS. \s0 It is nested two levels deep: transactions, then
locks.
.IP "\s-1DEADLOCK_TRANSACTIONS\s0" 4
.IX Item "DEADLOCK_TRANSACTIONS"
-This data is from the transaction list in the \s-1LATEST\s0 \s-1DETECTED\s0 \s-1DEADLOCK\s0
-section of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0. It is nested one level deep.
+This data is from the transaction list in the \s-1LATEST DETECTED DEADLOCK\s0
+section of \s-1SHOW INNODB STATUS. \s0 It is nested one level deep.
.IP "\s-1EXPLAIN\s0" 4
.IX Item "EXPLAIN"
-This data is from the result set returned by \s-1EXPLAIN\s0.
+This data is from the result set returned by \s-1EXPLAIN.\s0
+.IP "\s-1INNODB_BLOCKED_BLOCKER\s0" 4
+.IX Item "INNODB_BLOCKED_BLOCKER"
+This data is from the \s-1INFORMATION_SCHEMA\s0 tables related to InnoDB locks and
+the processlist.
.IP "\s-1INNODB_TRANSACTIONS\s0" 4
.IX Item "INNODB_TRANSACTIONS"
-This data is from the \s-1TRANSACTIONS\s0 section of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0.
+This data is from the \s-1TRANSACTIONS\s0 section of \s-1SHOW INNODB STATUS.\s0
.IP "\s-1IO_THREADS\s0" 4
.IX Item "IO_THREADS"
-This data is from the list of threads in the the \s-1FILE\s0 I/O section of \s-1SHOW\s0 \s-1INNODB\s0
-\&\s-1STATUS\s0.
+This data is from the list of threads in the the \s-1FILE I/O\s0 section of \s-1SHOW INNODB
+STATUS.\s0
.IP "\s-1INNODB_LOCKS\s0" 4
.IX Item "INNODB_LOCKS"
-This data is from the \s-1TRANSACTIONS\s0 section of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0 and is nested
+This data is from the \s-1TRANSACTIONS\s0 section of \s-1SHOW INNODB STATUS\s0 and is nested
two levels deep.
+.IP "\s-1MASTER_SLAVE\s0" 4
+.IX Item "MASTER_SLAVE"
+This data is from the combination of \s-1SHOW MASTER STATUS\s0 and \s-1SHOW SLAVE STATUS.\s0
.IP "\s-1OPEN_TABLES\s0" 4
.IX Item "OPEN_TABLES"
-This data is from \s-1SHOW\s0 \s-1OPEN\s0 \s-1TABLES\s0.
+This data is from \s-1SHOW OPEN TABLES.\s0
.IP "\s-1PROCESSLIST\s0" 4
.IX Item "PROCESSLIST"
-This data is from \s-1SHOW\s0 \s-1FULL\s0 \s-1PROCESSLIST\s0.
+This data is from \s-1SHOW FULL PROCESSLIST.\s0
+.IP "\s-1PROCESSLIST_STATS\s0" 4
+.IX Item "PROCESSLIST_STATS"
+This data is from \s-1SHOW FULL PROCESSLIST\s0 and computes stats such as the maximum time
+a user query has been running, and how many user queries are running. A \*(L"user
+query\*(R" excludes replication threads.
.IP "\s-1OS_WAIT_ARRAY\s0" 4
.IX Item "OS_WAIT_ARRAY"
-This data is from the \s-1SEMAPHORES\s0 section of \s-1SHOW\s0 \s-1INNODB\s0 \s-1STATUS\s0 and is nested one
+This data is from the \s-1SEMAPHORES\s0 section of \s-1SHOW INNODB STATUS\s0 and is nested one
level deep. It comes from the lines that look like this:
.Sp
.Vb 1
@@ -1976,15 +2091,15 @@ mode.
You need special privileges to start and stop slave servers.
.IP "\(bu" 4
You need appropriate privileges to create and drop the deadlock tables if needed
-(see \*(L"\s-1SERVER\s0 \s-1CONNECTIONS\s0\*(R").
+(see \*(L"\s-1SERVER CONNECTIONS\*(R"\s0).
.SH "SYSTEM REQUIREMENTS"
.IX Header "SYSTEM REQUIREMENTS"
-You need Perl to run innotop, of course. You also need a few Perl modules: \s-1DBI\s0,
+You need Perl to run innotop, of course. You also need a few Perl modules: \s-1DBI,\s0
DBD::mysql, Term::ReadKey, and Time::HiRes. These should be included with most
Perl distributions, but in case they are not, I recommend using versions
-distributed with your operating system or Perl distribution, not from \s-1CPAN\s0.
+distributed with your operating system or Perl distribution, not from \s-1CPAN.\s0
Term::ReadKey in particular has been known to cause problems if installed from
-\&\s-1CPAN\s0.
+\&\s-1CPAN.\s0
.PP
If you have Term::ANSIColor, innotop will use it to format headers more readably
and compactly. (Under Microsoft Windows, you also need Win32::Console::ANSI for
@@ -1992,7 +2107,7 @@ terminal formatting codes to be honored). If you install Term::ReadLine,
preferably Term::ReadLine::Gnu, you'll get nice auto-completion support.
.PP
I run innotop on Gentoo GNU/Linux, Debian and Ubuntu, and I've had feedback from
-people successfully running it on Red Hat, CentOS, Solaris, and Mac \s-1OSX\s0. I
+people successfully running it on Red Hat, CentOS, Solaris, and Mac \s-1OSX. I\s0
don't see any reason why it won't work on other UNIX-ish operating systems, but
I don't know for sure. It also runs on Windows under ActivePerl without
problem.
@@ -2017,6 +2132,7 @@ displays it.
The following people and organizations are acknowledged for various reasons.
Hopefully no one has been forgotten.
.PP
+Aaron Racine,
Allen K. Smith,
Aurimas Mikalauskas,
Bartosz Fenski,
@@ -2038,7 +2154,7 @@ Kristian Kohntopp,
Lenz Grimmer,
Maciej Dobrzanski,
Michiel Betel,
-MySQL \s-1AB\s0,
+MySQL \s-1AB,\s0
Paul McCullagh,
Sebastien Estienne,
Sourceforge.net,
@@ -2056,9 +2172,9 @@ not be able to compile it then).
This program is copyright (c) 2006 Baron Schwartz.
Feedback and improvements are welcome.
.PP
-\&\s-1THIS\s0 \s-1PROGRAM\s0 \s-1IS\s0 \s-1PROVIDED\s0 \*(L"\s-1AS\s0 \s-1IS\s0\*(R" \s-1AND\s0 \s-1WITHOUT\s0 \s-1ANY\s0 \s-1EXPRESS\s0 \s-1OR\s0 \s-1IMPLIED\s0
-\&\s-1WARRANTIES\s0, \s-1INCLUDING\s0, \s-1WITHOUT\s0 \s-1LIMITATION\s0, \s-1THE\s0 \s-1IMPLIED\s0 \s-1WARRANTIES\s0 \s-1OF\s0
-\&\s-1MERCHANTIBILITY\s0 \s-1AND\s0 \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0.
+\&\s-1THIS PROGRAM IS PROVIDED \*(L"AS IS\*(R" AND WITHOUT ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.\s0
.PP
This program is free software; you can redistribute it and/or modify it under
the terms of the \s-1GNU\s0 General Public License as published by the Free Software
@@ -2068,7 +2184,7 @@ licenses.
.PP
You should have received a copy of the \s-1GNU\s0 General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, \s-1MA\s0 02111\-1307 \s-1USA\s0.
+Place, Suite 330, Boston, \s-1MA 02111\-1307 USA.\s0
.PP
Execute innotop and press '!' to see this information at any time.
.SH "AUTHOR"
@@ -2077,7 +2193,7 @@ Originally written by Baron Schwartz; currently maintained by Aaron Racine.
.SH "BUGS"
.IX Header "BUGS"
You can report bugs, ask for improvements, and get other help and support at
-. There are mailing lists, a source code
+. There are mailing lists, a source code
browser, a bug tracker, etc. Please use these instead of contacting the
maintainer or author directly, as it makes our job easier and benefits others if the
discussions are permanent and public. Of course, if you need to contact us in
From ea31755760537723ded855794c16dd31c3db08c6 Mon Sep 17 00:00:00 2001
From: Christian Hesse
Date: Thu, 5 Jan 2017 12:07:26 +0100
Subject: [PATCH 140/226] properly set paths in systemd unit files
Use variables in systemd unit file templetes to properly set paths in
final systemd unit files.
---
support-files/CMakeLists.txt | 2 ++
support-files/mariadb.service.in | 10 +++++-----
support-files/mariadb@.service.in | 20 ++++++++++----------
3 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt
index c80de04d06927..c9addecafa515 100644
--- a/support-files/CMakeLists.txt
+++ b/support-files/CMakeLists.txt
@@ -90,6 +90,8 @@ IF(UNIX)
SET(scriptdir ${INSTALL_SCRIPTDIRABS})
SET(libexecdir ${INSTALL_SBINDIRABS})
SET(pkgdatadir ${INSTALL_MYSQLSHAREDIRABS})
+ SET(sysconfdir ${INSTALL_SYSCONFDIR})
+ SET(sysconf2dir ${INSTALL_SYSCONF2DIR})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql.server.sh
${CMAKE_CURRENT_BINARY_DIR}/mysql.server @ONLY)
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/mysql.server
diff --git a/support-files/mariadb.service.in b/support-files/mariadb.service.in
index 473f269986623..6a307b2c41f84 100644
--- a/support-files/mariadb.service.in
+++ b/support-files/mariadb.service.in
@@ -67,19 +67,19 @@ PermissionsStartOnly=true
# It is always safe to unset _WSREP_START_POSITION environment variable.
# Do not panic if galera_recovery script is not available. (MDEV-10538)
ExecStartPre=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION"
-ExecStartPre=/bin/sh -c "[ ! -e /usr/bin/galera_recovery ] && VAR= || \
- VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] \
+ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \
+ VAR=`@bindir@/galera_recovery`; [ $? -eq 0 ] \
&& systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1"
# Needed to create system tables etc.
-# ExecStartPre=/usr/bin/mysql_install_db -u mysql
+# ExecStartPre=@scriptdir@/mysql_install_db -u mysql
# Start main service
# MYSQLD_OPTS here is for users to set in /etc/systemd/system/mariadb.service.d/MY_SPECIAL.conf
# Use the [service] section and Environment="MYSQLD_OPTS=...".
# This isn't a replacement for my.cnf.
# _WSREP_NEW_CLUSTER is for the exclusive use of the script galera_new_cluster
-ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION
+ExecStart=@sbindir@/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION
@SYSTEMD_EXECSTARTPOST@
# Unset _WSREP_START_POSITION environment variable.
@@ -145,7 +145,7 @@ LimitNOFILE=16364
# ExecStartPre=sysctl -q -w vm.drop_caches=3
# numa-interleave=1 equalivant
-# Change ExecStart=numactl --interleave=all /usr/sbin/mysqld......
+# Change ExecStart=numactl --interleave=all @sbindir@/mysqld......
# crash-script equalivent
# FailureAction=
diff --git a/support-files/mariadb@.service.in b/support-files/mariadb@.service.in
index 1041933e3ec0b..410e7433b2b84 100644
--- a/support-files/mariadb@.service.in
+++ b/support-files/mariadb@.service.in
@@ -1,7 +1,7 @@
# Multi instance version of mariadb. For if you run multiple versions at once.
# Also used for mariadb@bootstrap to bootstrap Galera.
#
-# create config file @INSTALL_SYSCONF2DIR@/my{instancename}.cnf
+# create config file @sysconf2dir@/my{instancename}.cnf
#
# start as systemctl start mariadb@{instancename}.server
@@ -22,7 +22,7 @@ Description=MariaDB database server
After=network.target
After=syslog.target
-ConditionPathExists=@INSTALL_SYSCONF2DIR@/my%I.cnf
+ConditionPathExists=@sysconf2dir@/my%I.cnf
[Install]
WantedBy=multi-user.target
@@ -73,19 +73,19 @@ PermissionsStartOnly=true
# Do not panic if galera_recovery script is not available. (MDEV-10538)
ExecStartPre=/bin/sh -c "systemctl unset-environment _WSREP_START_POSITION%I"
-ExecStartPre=/bin/sh -c "[ ! -e /usr/bin/galera_recovery ] && VAR= || \
- VAR=`/usr/bin/galera_recovery --defaults-file=@INSTALL_SYSCONF2DIR@/my%I.cnf`; [ $? -eq 0 ] \
+ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \
+ VAR=`@bindir@/galera_recovery --defaults-file=@sysconf2dir@/my%I.cnf`; [ $? -eq 0 ] \
&& systemctl set-environment _WSREP_START_POSITION%I=$VAR || exit 1"
# Alternate: (remove ConditionPathExists above)
# use [mysqld.INSTANCENAME] as sections in my.cnf
#
-#ExecStartPre=/bin/sh -c "[ ! -e /usr/bin/galera_recovery ] && VAR= || \
-# VAR=`/usr/bin/galera_recovery --defaults-group-suffix=%I`; [ $? -eq 0 ] \
+#ExecStartPre=/bin/sh -c "[ ! -e @bindir@/galera_recovery ] && VAR= || \
+# VAR=`@bindir@/galera_recovery --defaults-group-suffix=%I`; [ $? -eq 0 ] \
# && systemctl set-environment _WSREP_START_POSITION%I=$VAR || exit 1"
# Needed to create system tables etc.
-# ExecStartPre=/usr/bin/mysql_install_db -u mysql
+# ExecStartPre=@scriptdir@/mysql_install_db -u mysql
# Start main service
# MYSQLD_OPTS here is for users to set in /etc/systemd/system/mariadb@.service.d/MY_SPECIAL.conf
@@ -95,12 +95,12 @@ ExecStartPre=/bin/sh -c "[ ! -e /usr/bin/galera_recovery ] && VAR= || \
# Note: Place $MYSQLD_OPTS at the very end for its options to take precedence.
-ExecStart=/usr/sbin/mysqld --defaults-file=@INSTALL_SYSCONF2DIR@/my%I.cnf \
+ExecStart=@sbindir@/mysqld --defaults-file=@sysconf2dir@/my%I.cnf \
$_WSREP_NEW_CLUSTER $_WSREP_START_POSITION%I $MYSQLD_OPTS
# Alternate: (remove ConditionPathExists above)
# use [mysqld.INSTANCENAME] as sections in my.cnf
#
-# ExecStart=/usr/sbin/mysqld --defaults-group-suffix=%I \
+# ExecStart=@sbindir@/mysqld --defaults-group-suffix=%I \
# $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION%I $MYSQLD_OPTS
# Unset _WSREP_START_POSITION environment variable.
@@ -166,7 +166,7 @@ LimitNOFILE=16364
# ExecStartPre=sysctl -q -w vm.drop_caches=3
# numa-interleave=1 equalivant
-# Change ExecStart=numactl --interleave=all /usr/sbin/mysqld......
+# Change ExecStart=numactl --interleave=all @sbindir@/mysqld......
# crash-script equalivent
# FailureAction=
From aeff61ee5857f2351030c604f62dc7628543209a Mon Sep 17 00:00:00 2001
From: Alexey Botchkov
Date: Tue, 7 Mar 2017 17:27:27 +0400
Subject: [PATCH 141/226] MDEV-12064 Bug#18411494 WRONG COMPARSION ON BIG
DECIMAL VALUES.
Test results updated.
---
mysql-test/r/select.result | 2 +-
mysql-test/r/select_jcl6.result | 2 +-
mysql-test/r/select_pkeycache.result | 2 +-
mysql-test/r/type_num.result | 29 ++++++++++++++--------------
4 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index ca8b235ba3185..787e321dd5725 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -2956,7 +2956,7 @@ insert into t1 values (1,'x',5);
select * from t1 natural join v1;
s1 s2 s3
Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: 'x'
+Warning 1292 Truncated incorrect DECIMAL value: 'x'
drop table t1;
drop view v1;
create table t1(a1 int);
diff --git a/mysql-test/r/select_jcl6.result b/mysql-test/r/select_jcl6.result
index 4659b0753edf8..10d8a05ad401a 100644
--- a/mysql-test/r/select_jcl6.result
+++ b/mysql-test/r/select_jcl6.result
@@ -2967,7 +2967,7 @@ insert into t1 values (1,'x',5);
select * from t1 natural join v1;
s1 s2 s3
Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: 'x'
+Warning 1292 Truncated incorrect DECIMAL value: 'x'
drop table t1;
drop view v1;
create table t1(a1 int);
diff --git a/mysql-test/r/select_pkeycache.result b/mysql-test/r/select_pkeycache.result
index ca8b235ba3185..787e321dd5725 100644
--- a/mysql-test/r/select_pkeycache.result
+++ b/mysql-test/r/select_pkeycache.result
@@ -2956,7 +2956,7 @@ insert into t1 values (1,'x',5);
select * from t1 natural join v1;
s1 s2 s3
Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: 'x'
+Warning 1292 Truncated incorrect DECIMAL value: 'x'
drop table t1;
drop view v1;
create table t1(a1 int);
diff --git a/mysql-test/r/type_num.result b/mysql-test/r/type_num.result
index 9ee67ac8f33e8..2eed7890e7564 100644
--- a/mysql-test/r/type_num.result
+++ b/mysql-test/r/type_num.result
@@ -570,7 +570,7 @@ SELECT COUNT(*) FROM t1 WHERE d='1 ';
COUNT(*)
2
Warnings:
-Note 1292 Truncated incorrect DOUBLE value: '1 '
+Note 1292 Truncated incorrect DECIMAL value: '1 '
SELECT COUNT(*) FROM t1 WHERE f4='';
COUNT(*)
2
@@ -605,7 +605,7 @@ SELECT COUNT(*) FROM t1 WHERE d='';
COUNT(*)
2
Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: ''
+Warning 1292 Truncated incorrect DECIMAL value: ''
SELECT COUNT(*) FROM t1 WHERE f4='x';
COUNT(*)
2
@@ -640,7 +640,7 @@ SELECT COUNT(*) FROM t1 WHERE d='x';
COUNT(*)
2
Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: 'x'
+Warning 1292 Truncated incorrect DECIMAL value: 'x'
SELECT COUNT(*) FROM t1 WHERE f4=' x';
COUNT(*)
2
@@ -675,7 +675,7 @@ SELECT COUNT(*) FROM t1 WHERE d=' x';
COUNT(*)
2
Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: ' x'
+Warning 1292 Truncated incorrect DECIMAL value: ' x'
SELECT COUNT(*) FROM t1 WHERE f4='.';
COUNT(*)
2
@@ -710,7 +710,7 @@ SELECT COUNT(*) FROM t1 WHERE d='.';
COUNT(*)
2
Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: '.'
+Warning 1292 Truncated incorrect DECIMAL value: '.'
SELECT COUNT(*) FROM t1 WHERE f4='-';
COUNT(*)
2
@@ -745,7 +745,7 @@ SELECT COUNT(*) FROM t1 WHERE d='-';
COUNT(*)
2
Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: '-'
+Warning 1292 Truncated incorrect DECIMAL value: '-'
SELECT COUNT(*) FROM t1 WHERE f4='+';
COUNT(*)
2
@@ -780,7 +780,7 @@ SELECT COUNT(*) FROM t1 WHERE d='+';
COUNT(*)
2
Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: '+'
+Warning 1292 Truncated incorrect DECIMAL value: '+'
SELECT COUNT(*) FROM t1 WHERE f4='1x';
COUNT(*)
2
@@ -815,7 +815,7 @@ SELECT COUNT(*) FROM t1 WHERE d='1x';
COUNT(*)
2
Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: '1x'
+Warning 1292 Truncated incorrect DECIMAL value: '1x'
SELECT COUNT(*) FROM t1 WHERE f4='1e';
COUNT(*)
2
@@ -850,7 +850,7 @@ SELECT COUNT(*) FROM t1 WHERE d='1e';
COUNT(*)
2
Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: '1e'
+Warning 1292 Truncated incorrect DECIMAL value: '1e'
SELECT COUNT(*) FROM t1 WHERE f4='1e+';
COUNT(*)
2
@@ -885,7 +885,7 @@ SELECT COUNT(*) FROM t1 WHERE d='1e+';
COUNT(*)
2
Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: '1e+'
+Warning 1292 Truncated incorrect DECIMAL value: '1e+'
SELECT COUNT(*) FROM t1 WHERE f4='1E-';
COUNT(*)
2
@@ -920,7 +920,7 @@ SELECT COUNT(*) FROM t1 WHERE d='1E-';
COUNT(*)
2
Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: '1E-'
+Warning 1292 Truncated incorrect DECIMAL value: '1E-'
SELECT COUNT(*) FROM t1 WHERE f4='1Ex';
COUNT(*)
2
@@ -955,7 +955,7 @@ SELECT COUNT(*) FROM t1 WHERE d='1Ex';
COUNT(*)
2
Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: '1Ex'
+Warning 1292 Truncated incorrect DECIMAL value: '1Ex'
SELECT COUNT(*) FROM t1 WHERE f4='1e+x';
COUNT(*)
2
@@ -990,7 +990,7 @@ SELECT COUNT(*) FROM t1 WHERE d='1e+x';
COUNT(*)
2
Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: '1e+x'
+Warning 1292 Truncated incorrect DECIMAL value: '1e+x'
SELECT COUNT(*) FROM t1 WHERE f4='1e1000';
COUNT(*)
0
@@ -1025,7 +1025,8 @@ SELECT COUNT(*) FROM t1 WHERE d='1e1000';
COUNT(*)
0
Warnings:
-Warning 1292 Truncated incorrect DOUBLE value: '1e1000'
+Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated.
+Warning 1292 Truncated incorrect DECIMAL value: '1e1000'
ALTER TABLE t1
ADD KEY f4(f4),
ADD KEY f8(f8),
From fa137476ff14a42c25f221585066d36124755f0a Mon Sep 17 00:00:00 2001
From: Sergey Vojtovich
Date: Fri, 3 Mar 2017 12:33:24 +0400
Subject: [PATCH 142/226] MDEV-11941 - Lintian complains about executable bits
Revoked executable bit from files that are not supposed to be executed directly.
Removed interpreted from files that are not supposed to be executed directly.
Added interpreter to files that are supposed to be executed directly.
---
mysql-test/lib/generate-ssl-certs.sh | 2 +-
.../suite/innodb/include/ibd_convert.pl | 1 -
.../parts/r/partition_exch_innodb.result | 0
.../parts/r/partition_exch_myisam.result | 0
.../r/partition_exch_myisam_innodb.result | 0
.../suite/parts/r/partition_exch_qa.result | 0
.../suite/parts/r/partition_exch_qa_11.result | 0
.../suite/parts/r/partition_exch_qa_14.result | 0
.../suite/parts/r/partition_exch_qa_3.result | 0
.../parts/r/partition_exch_qa_4_innodb.result | 0
.../parts/r/partition_exch_qa_4_myisam.result | 0
.../parts/r/partition_exch_qa_5_innodb.result | 0
.../parts/r/partition_exch_qa_5_myisam.result | 0
.../suite/parts/r/partition_exch_qa_6.result | 0
.../parts/r/partition_exch_qa_7_innodb.result | 0
.../parts/r/partition_exch_qa_7_myisam.result | 0
.../parts/r/partition_exch_qa_8_innodb.result | 0
.../parts/r/partition_exch_qa_8_myisam.result | 0
mysql-test/t/long_tmpdir-master.sh | 1 -
mysql-test/t/lowercase_mixed_tmpdir-master.sh | 1 -
.../t/lowercase_mixed_tmpdir_innodb-master.sh | 0
scripts/CMakeLists.txt | 49 +++++++++----------
.../{wsrep_sst_common.sh => wsrep_sst_common} | 0
.../generate_backing_table_tests_suite.sh | 3 +-
.../oqgraph/maintainer-general-record.sh | 1 +
25 files changed, 27 insertions(+), 31 deletions(-)
mode change 100755 => 100644 mysql-test/suite/parts/r/partition_exch_innodb.result
mode change 100755 => 100644 mysql-test/suite/parts/r/partition_exch_myisam.result
mode change 100755 => 100644 mysql-test/suite/parts/r/partition_exch_myisam_innodb.result
mode change 100755 => 100644 mysql-test/suite/parts/r/partition_exch_qa.result
mode change 100755 => 100644 mysql-test/suite/parts/r/partition_exch_qa_11.result
mode change 100755 => 100644 mysql-test/suite/parts/r/partition_exch_qa_14.result
mode change 100755 => 100644 mysql-test/suite/parts/r/partition_exch_qa_3.result
mode change 100755 => 100644 mysql-test/suite/parts/r/partition_exch_qa_4_innodb.result
mode change 100755 => 100644 mysql-test/suite/parts/r/partition_exch_qa_4_myisam.result
mode change 100755 => 100644 mysql-test/suite/parts/r/partition_exch_qa_5_innodb.result
mode change 100755 => 100644 mysql-test/suite/parts/r/partition_exch_qa_5_myisam.result
mode change 100755 => 100644 mysql-test/suite/parts/r/partition_exch_qa_6.result
mode change 100755 => 100644 mysql-test/suite/parts/r/partition_exch_qa_7_innodb.result
mode change 100755 => 100644 mysql-test/suite/parts/r/partition_exch_qa_7_myisam.result
mode change 100755 => 100644 mysql-test/suite/parts/r/partition_exch_qa_8_innodb.result
mode change 100755 => 100644 mysql-test/suite/parts/r/partition_exch_qa_8_myisam.result
mode change 100755 => 100644 mysql-test/t/long_tmpdir-master.sh
mode change 100755 => 100644 mysql-test/t/lowercase_mixed_tmpdir-master.sh
mode change 100755 => 100644 mysql-test/t/lowercase_mixed_tmpdir_innodb-master.sh
rename scripts/{wsrep_sst_common.sh => wsrep_sst_common} (100%)
diff --git a/mysql-test/lib/generate-ssl-certs.sh b/mysql-test/lib/generate-ssl-certs.sh
index 5dca21a755d99..cc919dfe32e6e 100755
--- a/mysql-test/lib/generate-ssl-certs.sh
+++ b/mysql-test/lib/generate-ssl-certs.sh
@@ -1,4 +1,4 @@
-#/bin/sh -xe
+#!/bin/sh -xe
# simply run me from mysql-test/
cd std_data/
diff --git a/mysql-test/suite/innodb/include/ibd_convert.pl b/mysql-test/suite/innodb/include/ibd_convert.pl
index 32eef96fd23d6..9c7e829f45584 100644
--- a/mysql-test/suite/innodb/include/ibd_convert.pl
+++ b/mysql-test/suite/innodb/include/ibd_convert.pl
@@ -1,4 +1,3 @@
-#!/usr/bin/perl
# Convert tablespace flags to the format understood by MariaDB 10.1.0..10.1.20,
# with the assumption that the flags were correct.
diff --git a/mysql-test/suite/parts/r/partition_exch_innodb.result b/mysql-test/suite/parts/r/partition_exch_innodb.result
old mode 100755
new mode 100644
diff --git a/mysql-test/suite/parts/r/partition_exch_myisam.result b/mysql-test/suite/parts/r/partition_exch_myisam.result
old mode 100755
new mode 100644
diff --git a/mysql-test/suite/parts/r/partition_exch_myisam_innodb.result b/mysql-test/suite/parts/r/partition_exch_myisam_innodb.result
old mode 100755
new mode 100644
diff --git a/mysql-test/suite/parts/r/partition_exch_qa.result b/mysql-test/suite/parts/r/partition_exch_qa.result
old mode 100755
new mode 100644
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_11.result b/mysql-test/suite/parts/r/partition_exch_qa_11.result
old mode 100755
new mode 100644
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_14.result b/mysql-test/suite/parts/r/partition_exch_qa_14.result
old mode 100755
new mode 100644
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_3.result b/mysql-test/suite/parts/r/partition_exch_qa_3.result
old mode 100755
new mode 100644
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_4_innodb.result b/mysql-test/suite/parts/r/partition_exch_qa_4_innodb.result
old mode 100755
new mode 100644
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_4_myisam.result b/mysql-test/suite/parts/r/partition_exch_qa_4_myisam.result
old mode 100755
new mode 100644
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_5_innodb.result b/mysql-test/suite/parts/r/partition_exch_qa_5_innodb.result
old mode 100755
new mode 100644
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_5_myisam.result b/mysql-test/suite/parts/r/partition_exch_qa_5_myisam.result
old mode 100755
new mode 100644
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_6.result b/mysql-test/suite/parts/r/partition_exch_qa_6.result
old mode 100755
new mode 100644
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_7_innodb.result b/mysql-test/suite/parts/r/partition_exch_qa_7_innodb.result
old mode 100755
new mode 100644
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_7_myisam.result b/mysql-test/suite/parts/r/partition_exch_qa_7_myisam.result
old mode 100755
new mode 100644
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_8_innodb.result b/mysql-test/suite/parts/r/partition_exch_qa_8_innodb.result
old mode 100755
new mode 100644
diff --git a/mysql-test/suite/parts/r/partition_exch_qa_8_myisam.result b/mysql-test/suite/parts/r/partition_exch_qa_8_myisam.result
old mode 100755
new mode 100644
diff --git a/mysql-test/t/long_tmpdir-master.sh b/mysql-test/t/long_tmpdir-master.sh
old mode 100755
new mode 100644
index 7bcbee26105d5..318955fbcca31
--- a/mysql-test/t/long_tmpdir-master.sh
+++ b/mysql-test/t/long_tmpdir-master.sh
@@ -1,4 +1,3 @@
-#!/bin/sh
d="$MYSQLTEST_VARDIR/tmp/long_temporary_directory_path_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789"
test -d "$d" || mkdir "$d"
rm -f "$d"/*
diff --git a/mysql-test/t/lowercase_mixed_tmpdir-master.sh b/mysql-test/t/lowercase_mixed_tmpdir-master.sh
old mode 100755
new mode 100644
index 9330d0581ee2c..95c26e3aa0234
--- a/mysql-test/t/lowercase_mixed_tmpdir-master.sh
+++ b/mysql-test/t/lowercase_mixed_tmpdir-master.sh
@@ -1,4 +1,3 @@
-#!/bin/sh
# This test requires a non-lowercase tmpdir directory on a case-sensitive
# filesystem.
diff --git a/mysql-test/t/lowercase_mixed_tmpdir_innodb-master.sh b/mysql-test/t/lowercase_mixed_tmpdir_innodb-master.sh
old mode 100755
new mode 100644
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index d960f792a95ad..148dddccf30d1 100644
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -73,6 +73,23 @@ IF(UNIX)
)
ENDIF()
+# Configure two scripts from one 'in' file.
+# The maria_add_gis_sp.sql - to be sent to 'mysql' tool
+# and the maria_add_gis_sp_bootstrap.sql, that can be sent to
+# the server as a bootstrap command.
+
+SET(ADD_GIS_SP_SET_DELIMITER "delimiter |")
+SET(ADD_GIS_SP_RESET_DELIMITER "delimiter ;")
+SET(ADD_GIS_SP_EOL "|")
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/maria_add_gis_sp.sql.in
+ ${CMAKE_CURRENT_BINARY_DIR}/maria_add_gis_sp.sql ESCAPE_QUOTES @ONLY)
+
+SET(ADD_GIS_SP_SET_DELIMITER "")
+SET(ADD_GIS_SP_RESET_DELIMITER "")
+SET(ADD_GIS_SP_EOL ";")
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/maria_add_gis_sp.sql.in
+ ${CMAKE_CURRENT_BINARY_DIR}/maria_add_gis_sp_bootstrap.sql ESCAPE_QUOTES @ONLY)
+
INSTALL(FILES
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables.sql
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables_data.sql
@@ -80,6 +97,8 @@ INSTALL(FILES
${CMAKE_CURRENT_SOURCE_DIR}/fill_help_tables.sql
${CMAKE_CURRENT_SOURCE_DIR}/mysql_test_data_timezone.sql
${CMAKE_CURRENT_SOURCE_DIR}/mysql_to_mariadb.sql
+ ${CMAKE_CURRENT_BINARY_DIR}/maria_add_gis_sp.sql
+ ${CMAKE_CURRENT_BINARY_DIR}/maria_add_gis_sp_bootstrap.sql
${FIX_PRIVILEGES_SQL}
DESTINATION ${INSTALL_MYSQLSHAREDIR} COMPONENT Server
)
@@ -270,13 +289,14 @@ IF(WIN32)
ENDFOREACH()
ELSE()
IF(WITH_WSREP)
- SET(WSREP_BINARIES
- wsrep_sst_common
+ SET(WSREP_SCRIPTS
wsrep_sst_mysqldump
wsrep_sst_rsync
wsrep_sst_xtrabackup
wsrep_sst_xtrabackup-v2
)
+ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/wsrep_sst_common
+ DESTINATION ${INSTALL_BINDIR} COMPONENT Server)
ENDIF()
IF (NOT WITHOUT_SERVER)
SET(SERVER_SCRIPTS
@@ -302,7 +322,7 @@ ELSE()
mytop
mysqlhotcopy
${SERVER_SCRIPTS}
- ${WSREP_BINARIES}
+ ${WSREP_SCRIPTS}
${SYSTEMD_SCRIPTS}
)
FOREACH(file ${BIN_SCRIPTS})
@@ -328,29 +348,6 @@ ELSE()
ENDFOREACH()
ENDIF()
-# Configure two scripts from one 'in' file.
-# The maria_add_gis_sp.sql - to be sent to 'mysql' tool
-# and the maria_add_gis_sp_bootstrap.sql, that can be sent to
-# the server as a bootstrap command.
-
-SET(ADD_GIS_SP_SET_DELIMITER "delimiter |")
-SET(ADD_GIS_SP_RESET_DELIMITER "delimiter ;")
-SET(ADD_GIS_SP_EOL "|")
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/maria_add_gis_sp.sql.in
- ${CMAKE_CURRENT_BINARY_DIR}/maria_add_gis_sp.sql ESCAPE_QUOTES @ONLY)
-
-SET(ADD_GIS_SP_SET_DELIMITER "")
-SET(ADD_GIS_SP_RESET_DELIMITER "")
-SET(ADD_GIS_SP_EOL ";")
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/maria_add_gis_sp.sql.in
- ${CMAKE_CURRENT_BINARY_DIR}/maria_add_gis_sp_bootstrap.sql ESCAPE_QUOTES @ONLY)
-
-INSTALL_SCRIPT(${CMAKE_CURRENT_BINARY_DIR}/maria_add_gis_sp.sql
- ${CMAKE_CURRENT_BINARY_DIR}/maria_add_gis_sp_bootstrap.sql
- DESTINATION ${INSTALL_MYSQLSHAREDIR}
- COMPONENT Server
- )
-
# Install libgcc as mylibgcc.a
IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_FLAGS MATCHES "-static")
EXECUTE_PROCESS (
diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common
similarity index 100%
rename from scripts/wsrep_sst_common.sh
rename to scripts/wsrep_sst_common
diff --git a/storage/oqgraph/mysql-test/oqgraph/generate_backing_table_tests_suite.sh b/storage/oqgraph/mysql-test/oqgraph/generate_backing_table_tests_suite.sh
index 087b2b7089c05..22feaab5c3a27 100755
--- a/storage/oqgraph/mysql-test/oqgraph/generate_backing_table_tests_suite.sh
+++ b/storage/oqgraph/mysql-test/oqgraph/generate_backing_table_tests_suite.sh
@@ -45,7 +45,8 @@ done
# Intended to be run from build as ../storage/oqgraph/mysql-test/oqgraph/maintainer-general-record.sh
MGFILE=maintainer-general-record.sh
-echo '# This is a maintainer generated file. Generated at '`date`'.' > $MGFILE
+echo '#!/bin/sh' > $MGFILE
+echo '# This is a maintainer generated file. Generated at '`date`'.' >> $MGFILE
for ENGINE in $ENGINES $ENGINES2 ; do
echo mysql-test/mysql-test-run --record oqgraph.general-$ENGINE >> $MGFILE
done
diff --git a/storage/oqgraph/mysql-test/oqgraph/maintainer-general-record.sh b/storage/oqgraph/mysql-test/oqgraph/maintainer-general-record.sh
index bc68401505535..7af12013e532a 100755
--- a/storage/oqgraph/mysql-test/oqgraph/maintainer-general-record.sh
+++ b/storage/oqgraph/mysql-test/oqgraph/maintainer-general-record.sh
@@ -1,3 +1,4 @@
+#!/bin/sh
# This is a maintainer generated file. Generated at Wednesday 5 February 22:26:12 CST 2014.
mysql-test/mysql-test-run --record oqgraph.general-MyISAM
mysql-test/mysql-test-run --record oqgraph.general-MEMORY
From 19629ebf813ef7825eb86a46045ebccdfd484d9a Mon Sep 17 00:00:00 2001
From: Sergey Vojtovich
Date: Tue, 7 Mar 2017 15:06:01 +0400
Subject: [PATCH 143/226] MDEV-10646 - System Unit File After network-online
Bind to an address even if it is not yet configured.
---
sql/mysqld.cc | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 90607882aa458..2607307ceee8c 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2520,6 +2520,12 @@ static MYSQL_SOCKET activate_tcp_port(uint port)
(char*)&arg, sizeof(arg));
}
#endif
+
+#ifdef IP_FREEBIND
+ arg= 1;
+ (void) mysql_socket_setsockopt(ip_sock, IPPROTO_IP, IP_FREEBIND, (char*) &arg,
+ sizeof(arg));
+#endif
/*
Sometimes the port is not released fast enough when stopping and
restarting the server. This happens quite often with the test suite
From 17a1b194e26f19935fe1be08e974f475d52190e3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?=
Date: Wed, 8 Mar 2017 10:03:35 +0200
Subject: [PATCH 144/226] Fix some GCC 6.3.0 warnings in MyISAM and Maria.
The C++ standard does not allow references to be NULL.
Assign the return value of THD::alloc() to a pointer,
not to a reference.
---
storage/maria/ha_maria.cc | 226 ++++++++++++++++++------------------
storage/myisam/ha_myisam.cc | 200 +++++++++++++++----------------
2 files changed, 213 insertions(+), 213 deletions(-)
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index 60e3f62096d34..44f7b466a2a73 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -1,6 +1,6 @@
/* Copyright (C) 2004-2008 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
Copyright (C) 2008-2009 Sun Microsystems, Inc.
- Copyright (c) 2009, 2014, SkySQL Ab.
+ Copyright (c) 2009, 2017, 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
@@ -1271,75 +1271,75 @@ int ha_maria::write_row(uchar * buf)
int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt)
{
int error;
- HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param));
+ HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
MARIA_SHARE *share= file->s;
const char *old_proc_info;
TRN *old_trn= file->trn;
- if (!file || !¶m) return HA_ADMIN_INTERNAL_ERROR;
+ if (!file || !param) return HA_ADMIN_INTERNAL_ERROR;
- maria_chk_init(¶m);
- param.thd= thd;
- param.op_name= "check";
- param.db_name= table->s->db.str;
- param.table_name= table->alias.c_ptr();
- param.testflag= check_opt->flags | T_CHECK | T_SILENT;
- param.stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method);
+ maria_chk_init(param);
+ param->thd= thd;
+ param->op_name= "check";
+ param->db_name= table->s->db.str;
+ param->table_name= table->alias.c_ptr();
+ param->testflag= check_opt->flags | T_CHECK | T_SILENT;
+ param->stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method);
if (!(table->db_stat & HA_READ_ONLY))
- param.testflag |= T_STATISTICS;
- param.using_global_keycache= 1;
+ param->testflag |= T_STATISTICS;
+ param->using_global_keycache= 1;
if (!maria_is_crashed(file) &&
- (((param.testflag & T_CHECK_ONLY_CHANGED) &&
+ (((param->testflag & T_CHECK_ONLY_CHANGED) &&
!(share->state.changed & (STATE_CHANGED | STATE_CRASHED_FLAGS |
STATE_IN_REPAIR)) &&
share->state.open_count == 0) ||
- ((param.testflag & T_FAST) && (share->state.open_count ==
+ ((param->testflag & T_FAST) && (share->state.open_count ==
(uint) (share->global_changed ? 1 :
0)))))
return HA_ADMIN_ALREADY_DONE;
- maria_chk_init_for_check(¶m, file);
+ maria_chk_init_for_check(param, file);
if ((file->s->state.changed & (STATE_CRASHED_FLAGS | STATE_MOVED)) ==
STATE_MOVED)
{
- _ma_check_print_error(¶m, "%s", zerofill_error_msg);
+ _ma_check_print_error(param, "%s", zerofill_error_msg);
return HA_ADMIN_CORRUPT;
}
old_proc_info= thd_proc_info(thd, "Checking status");
thd_progress_init(thd, 3);
- error= maria_chk_status(¶m, file); // Not fatal
- if (maria_chk_size(¶m, file))
+ error= maria_chk_status(param, file); // Not fatal
+ if (maria_chk_size(param, file))
error= 1;
if (!error)
- error|= maria_chk_del(¶m, file, param.testflag);
+ error|= maria_chk_del(param, file, param->testflag);
thd_proc_info(thd, "Checking keys");
thd_progress_next_stage(thd);
if (!error)
- error= maria_chk_key(¶m, file);
+ error= maria_chk_key(param, file);
thd_proc_info(thd, "Checking data");
thd_progress_next_stage(thd);
if (!error)
{
- if ((!(param.testflag & T_QUICK) &&
+ if ((!(param->testflag & T_QUICK) &&
((share->options &
(HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) ||
- (param.testflag & (T_EXTEND | T_MEDIUM)))) || maria_is_crashed(file))
+ (param->testflag & (T_EXTEND | T_MEDIUM)))) || maria_is_crashed(file))
{
- ulonglong old_testflag= param.testflag;
- param.testflag |= T_MEDIUM;
- if (!(error= init_io_cache(¶m.read_cache, file->dfile.file,
+ ulonglong old_testflag= param->testflag;
+ param->testflag |= T_MEDIUM;
+ if (!(error= init_io_cache(¶m->read_cache, file->dfile.file,
my_default_record_cache_size, READ_CACHE,
share->pack.header_length, 1, MYF(MY_WME))))
{
- error= maria_chk_data_link(¶m, file,
- test(param.testflag & T_EXTEND));
- end_io_cache(&(param.read_cache));
+ error= maria_chk_data_link(param, file,
+ test(param->testflag & T_EXTEND));
+ end_io_cache(¶m->read_cache);
}
- param.testflag= old_testflag;
+ param->testflag= old_testflag;
}
}
if (!error)
@@ -1347,7 +1347,7 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt)
if ((share->state.changed & (STATE_CHANGED |
STATE_CRASHED_FLAGS |
STATE_IN_REPAIR | STATE_NOT_ANALYZED)) ||
- (param.testflag & T_STATISTICS) || maria_is_crashed(file))
+ (param->testflag & T_STATISTICS) || maria_is_crashed(file))
{
file->update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
mysql_mutex_lock(&share->intern_lock);
@@ -1355,7 +1355,7 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt)
share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED_FLAGS |
STATE_IN_REPAIR);
if (!(table->db_stat & HA_READ_ONLY))
- error= maria_update_state_info(¶m, file,
+ error= maria_update_state_info(param, file,
UPDATE_TIME | UPDATE_OPEN_COUNT |
UPDATE_STAT);
mysql_mutex_unlock(&share->intern_lock);
@@ -1386,33 +1386,33 @@ int ha_maria::check(THD * thd, HA_CHECK_OPT * check_opt)
int ha_maria::analyze(THD *thd, HA_CHECK_OPT * check_opt)
{
int error= 0;
- HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param));
+ HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
MARIA_SHARE *share= file->s;
const char *old_proc_info;
- if (!¶m)
+ if (!param)
return HA_ADMIN_INTERNAL_ERROR;
- maria_chk_init(¶m);
- param.thd= thd;
- param.op_name= "analyze";
- param.db_name= table->s->db.str;
- param.table_name= table->alias.c_ptr();
- param.testflag= (T_FAST | T_CHECK | T_SILENT | T_STATISTICS |
+ maria_chk_init(param);
+ param->thd= thd;
+ param->op_name= "analyze";
+ param->db_name= table->s->db.str;
+ param->table_name= table->alias.c_ptr();
+ param->testflag= (T_FAST | T_CHECK | T_SILENT | T_STATISTICS |
T_DONT_CHECK_CHECKSUM);
- param.using_global_keycache= 1;
- param.stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method);
+ param->using_global_keycache= 1;
+ param->stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method);
if (!(share->state.changed & STATE_NOT_ANALYZED))
return HA_ADMIN_ALREADY_DONE;
old_proc_info= thd_proc_info(thd, "Scanning");
thd_progress_init(thd, 1);
- error= maria_chk_key(¶m, file);
+ error= maria_chk_key(param, file);
if (!error)
{
mysql_mutex_lock(&share->intern_lock);
- error= maria_update_state_info(¶m, file, UPDATE_STAT);
+ error= maria_update_state_info(param, file, UPDATE_STAT);
mysql_mutex_unlock(&share->intern_lock);
}
else if (!maria_is_crashed(file) && !thd->killed)
@@ -1425,44 +1425,44 @@ int ha_maria::analyze(THD *thd, HA_CHECK_OPT * check_opt)
int ha_maria::repair(THD * thd, HA_CHECK_OPT *check_opt)
{
int error;
- HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param));
+ HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
ha_rows start_records;
const char *old_proc_info;
- if (!file || !¶m)
+ if (!file || !param)
return HA_ADMIN_INTERNAL_ERROR;
- maria_chk_init(¶m);
- param.thd= thd;
- param.op_name= "repair";
- param.testflag= ((check_opt->flags & ~(T_EXTEND)) |
+ maria_chk_init(param);
+ param->thd= thd;
+ param->op_name= "repair";
+ param->testflag= ((check_opt->flags & ~(T_EXTEND)) |
T_SILENT | T_FORCE_CREATE | T_CALC_CHECKSUM |
(check_opt->flags & T_EXTEND ? T_REP : T_REP_BY_SORT));
- param.sort_buffer_length= THDVAR(thd, sort_buffer_size);
- param.backup_time= check_opt->start_time;
+ param->sort_buffer_length= THDVAR(thd, sort_buffer_size);
+ param->backup_time= check_opt->start_time;
start_records= file->state->records;
old_proc_info= thd_proc_info(thd, "Checking table");
thd_progress_init(thd, 1);
- while ((error= repair(thd, ¶m, 0)) && param.retry_repair)
+ while ((error= repair(thd, param, 0)) && param->retry_repair)
{
- param.retry_repair= 0;
- if (test_all_bits(param.testflag,
+ param->retry_repair= 0;
+ if (test_all_bits(param->testflag,
(uint) (T_RETRY_WITHOUT_QUICK | T_QUICK)))
{
- param.testflag&= ~(T_RETRY_WITHOUT_QUICK | T_QUICK);
+ param->testflag&= ~(T_RETRY_WITHOUT_QUICK | T_QUICK);
/* Ensure we don't loose any rows when retrying without quick */
- param.testflag|= T_SAFE_REPAIR;
+ param->testflag|= T_SAFE_REPAIR;
if (thd->vio_ok())
- _ma_check_print_info(¶m, "Retrying repair without quick");
+ _ma_check_print_info(param, "Retrying repair without quick");
else
sql_print_information("Retrying repair of: '%s' without quick",
table->s->path.str);
continue;
}
- param.testflag &= ~T_QUICK;
- if ((param.testflag & T_REP_BY_SORT))
+ param->testflag &= ~T_QUICK;
+ if (param->testflag & T_REP_BY_SORT)
{
- param.testflag= (param.testflag & ~T_REP_BY_SORT) | T_REP;
+ param->testflag= (param->testflag & ~T_REP_BY_SORT) | T_REP;
sql_print_information("Retrying repair of: '%s' with keycache",
table->s->path.str);
continue;
@@ -1486,20 +1486,20 @@ int ha_maria::repair(THD * thd, HA_CHECK_OPT *check_opt)
int ha_maria::zerofill(THD * thd, HA_CHECK_OPT *check_opt)
{
int error;
- HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param));
+ HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
TRN *old_trn;
MARIA_SHARE *share= file->s;
- if (!file || !¶m)
+ if (!file || !param)
return HA_ADMIN_INTERNAL_ERROR;
old_trn= file->trn;
- maria_chk_init(¶m);
- param.thd= thd;
- param.op_name= "zerofill";
- param.testflag= check_opt->flags | T_SILENT | T_ZEROFILL;
- param.sort_buffer_length= THDVAR(thd, sort_buffer_size);
- error=maria_zerofill(¶m, file, share->open_file_name.str);
+ maria_chk_init(param);
+ param->thd= thd;
+ param->op_name= "zerofill";
+ param->testflag= check_opt->flags | T_SILENT | T_ZEROFILL;
+ param->sort_buffer_length= THDVAR(thd, sort_buffer_size);
+ error=maria_zerofill(param, file, share->open_file_name.str);
/* Reset trn, that may have been set by repair */
_ma_set_trn_for_table(file, old_trn);
@@ -1509,7 +1509,7 @@ int ha_maria::zerofill(THD * thd, HA_CHECK_OPT *check_opt)
TrID create_trid= trnman_get_min_safe_trid();
mysql_mutex_lock(&share->intern_lock);
share->state.changed|= STATE_NOT_MOVABLE;
- maria_update_state_info(¶m, file, UPDATE_TIME | UPDATE_OPEN_COUNT);
+ maria_update_state_info(param, file, UPDATE_TIME | UPDATE_OPEN_COUNT);
_ma_update_state_lsns_sub(share, LSN_IMPOSSIBLE, create_trid,
TRUE, TRUE);
mysql_mutex_unlock(&share->intern_lock);
@@ -1520,24 +1520,24 @@ int ha_maria::zerofill(THD * thd, HA_CHECK_OPT *check_opt)
int ha_maria::optimize(THD * thd, HA_CHECK_OPT *check_opt)
{
int error;
- HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param));
+ HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
- if (!file || !¶m)
+ if (!file || !param)
return HA_ADMIN_INTERNAL_ERROR;
- maria_chk_init(¶m);
- param.thd= thd;
- param.op_name= "optimize";
- param.testflag= (check_opt->flags | T_SILENT | T_FORCE_CREATE |
+ maria_chk_init(param);
+ param->thd= thd;
+ param->op_name= "optimize";
+ param->testflag= (check_opt->flags | T_SILENT | T_FORCE_CREATE |
T_REP_BY_SORT | T_STATISTICS | T_SORT_INDEX);
- param.sort_buffer_length= THDVAR(thd, sort_buffer_size);
+ param->sort_buffer_length= THDVAR(thd, sort_buffer_size);
thd_progress_init(thd, 1);
- if ((error= repair(thd, ¶m, 1)) && param.retry_repair)
+ if ((error= repair(thd, param, 1)) && param->retry_repair)
{
sql_print_warning("Warning: Optimize table got errno %d on %s.%s, retrying",
- my_errno, param.db_name, param.table_name);
- param.testflag &= ~T_REP_BY_SORT;
- error= repair(thd, ¶m, 0);
+ my_errno, param->db_name, param->table_name);
+ param->testflag &= ~T_REP_BY_SORT;
+ error= repair(thd, param, 0);
}
thd_progress_end(thd);
return error;
@@ -1782,17 +1782,17 @@ int ha_maria::assign_to_keycache(THD * thd, HA_CHECK_OPT *check_opt)
if (error != HA_ADMIN_OK)
{
/* Send error to user */
- HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param));
- if (!¶m)
+ HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
+ if (!param)
return HA_ADMIN_INTERNAL_ERROR;
- maria_chk_init(¶m);
- param.thd= thd;
- param.op_name= "assign_to_keycache";
- param.db_name= table->s->db.str;
- param.table_name= table->s->table_name.str;
- param.testflag= 0;
- _ma_check_print_error(¶m, errmsg);
+ maria_chk_init(param);
+ param->thd= thd;
+ param->op_name= "assign_to_keycache";
+ param->db_name= table->s->db.str;
+ param->table_name= table->s->table_name.str;
+ param->testflag= 0;
+ _ma_check_print_error(param, errmsg);
}
DBUG_RETURN(error);
#else
@@ -1846,17 +1846,17 @@ int ha_maria::preload_keys(THD * thd, HA_CHECK_OPT *check_opt)
errmsg= buf;
}
- HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param));
- if (!¶m)
+ HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
+ if (!param)
return HA_ADMIN_INTERNAL_ERROR;
- maria_chk_init(¶m);
- param.thd= thd;
- param.op_name= "preload_keys";
- param.db_name= table->s->db.str;
- param.table_name= table->s->table_name.str;
- param.testflag= 0;
- _ma_check_print_error(¶m, "%s", errmsg);
+ maria_chk_init(param);
+ param->thd= thd;
+ param->op_name= "preload_keys";
+ param->db_name= table->s->db.str;
+ param->table_name= table->s->table_name.str;
+ param->testflag= 0;
+ _ma_check_print_error(param, "%s", errmsg);
DBUG_RETURN(HA_ADMIN_FAILED);
}
DBUG_RETURN(HA_ADMIN_OK);
@@ -1957,22 +1957,22 @@ int ha_maria::enable_indexes(uint mode)
else if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE)
{
THD *thd= table->in_use;
- HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param));
- if (!¶m)
+ HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
+ if (!param)
return HA_ADMIN_INTERNAL_ERROR;
const char *save_proc_info= thd_proc_info(thd, "Creating index");
- maria_chk_init(¶m);
- param.op_name= "recreating_index";
- param.testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK |
+ maria_chk_init(param);
+ param->op_name= "recreating_index";
+ param->testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK |
T_CREATE_MISSING_KEYS | T_SAFE_REPAIR);
/*
Don't lock and unlock table if it's locked.
Normally table should be locked. This test is mostly for safety.
*/
if (likely(file->lock_type != F_UNLCK))
- param.testflag|= T_NO_LOCKS;
+ param->testflag|= T_NO_LOCKS;
if (bulk_insert_single_undo == BULK_INSERT_SINGLE_UNDO_AND_NO_REPAIR)
{
@@ -1981,23 +1981,23 @@ int ha_maria::enable_indexes(uint mode)
Don't bump create_rename_lsn, because UNDO_BULK_INSERT
should not be skipped in case of crash during repair.
*/
- param.testflag|= T_NO_CREATE_RENAME_LSN;
+ param->testflag|= T_NO_CREATE_RENAME_LSN;
}
- param.myf_rw &= ~MY_WAIT_IF_FULL;
- param.sort_buffer_length= THDVAR(thd,sort_buffer_size);
- param.stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method);
- param.tmpdir= &mysql_tmpdir_list;
- if ((error= (repair(thd, ¶m, 0) != HA_ADMIN_OK)) && param.retry_repair)
+ param->myf_rw &= ~MY_WAIT_IF_FULL;
+ param->sort_buffer_length= THDVAR(thd,sort_buffer_size);
+ param->stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method);
+ param->tmpdir= &mysql_tmpdir_list;
+ if ((error= (repair(thd, param, 0) != HA_ADMIN_OK)) && param->retry_repair)
{
sql_print_warning("Warning: Enabling keys got errno %d on %s.%s, "
"retrying",
- my_errno, param.db_name, param.table_name);
+ my_errno, param->db_name, param->table_name);
/* This should never fail normally */
DBUG_ASSERT(thd->killed != 0);
/* Repairing by sort failed. Now try standard repair method. */
- param.testflag &= ~T_REP_BY_SORT;
- error= (repair(thd, ¶m, 0) != HA_ADMIN_OK);
+ param->testflag &= ~T_REP_BY_SORT;
+ error= (repair(thd, param, 0) != HA_ADMIN_OK);
/*
If the standard repair succeeded, clear all error messages which
might have been set by the first repair. They can still be seen
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index ddbd14010b999..f63b9c85372b6 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2012, Oracle and/or its affiliates.
- Copyright (c) 2009, 2014, SkySQL Ab.
+ Copyright (c) 2009, 2017, 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
@@ -856,59 +856,59 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
{
if (!file) return HA_ADMIN_INTERNAL_ERROR;
int error;
- HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param));
+ HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
MYISAM_SHARE* share = file->s;
const char *old_proc_info=thd->proc_info;
- if (!¶m)
+ if (!param)
return HA_ADMIN_INTERNAL_ERROR;
thd_proc_info(thd, "Checking table");
- myisamchk_init(¶m);
- param.thd = thd;
- param.op_name = "check";
- param.db_name= table->s->db.str;
- param.table_name= table->alias.c_ptr();
- param.testflag = check_opt->flags | T_CHECK | T_SILENT;
- param.stats_method= (enum_handler_stats_method)THDVAR(thd, stats_method);
+ myisamchk_init(param);
+ param->thd = thd;
+ param->op_name = "check";
+ param->db_name= table->s->db.str;
+ param->table_name= table->alias.c_ptr();
+ param->testflag = check_opt->flags | T_CHECK | T_SILENT;
+ param->stats_method= (enum_handler_stats_method)THDVAR(thd, stats_method);
if (!(table->db_stat & HA_READ_ONLY))
- param.testflag|= T_STATISTICS;
- param.using_global_keycache = 1;
+ param->testflag|= T_STATISTICS;
+ param->using_global_keycache = 1;
if (!mi_is_crashed(file) &&
- (((param.testflag & T_CHECK_ONLY_CHANGED) &&
+ (((param->testflag & T_CHECK_ONLY_CHANGED) &&
!(share->state.changed & (STATE_CHANGED | STATE_CRASHED |
STATE_CRASHED_ON_REPAIR)) &&
share->state.open_count == 0) ||
- ((param.testflag & T_FAST) && (share->state.open_count ==
+ ((param->testflag & T_FAST) && (share->state.open_count ==
(uint) (share->global_changed ? 1 : 0)))))
return HA_ADMIN_ALREADY_DONE;
- error = chk_status(¶m, file); // Not fatal
- error = chk_size(¶m, file);
+ error = chk_status(param, file); // Not fatal
+ error = chk_size(param, file);
if (!error)
- error |= chk_del(¶m, file, param.testflag);
+ error |= chk_del(param, file, param->testflag);
if (!error)
- error = chk_key(¶m, file);
+ error = chk_key(param, file);
if (!error)
{
- if ((!(param.testflag & T_QUICK) &&
+ if ((!(param->testflag & T_QUICK) &&
((share->options &
(HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) ||
- (param.testflag & (T_EXTEND | T_MEDIUM)))) ||
+ (param->testflag & (T_EXTEND | T_MEDIUM)))) ||
mi_is_crashed(file))
{
- ulonglong old_testflag= param.testflag;
- param.testflag|=T_MEDIUM;
- if (!(error= init_io_cache(¶m.read_cache, file->dfile,
+ ulonglong old_testflag= param->testflag;
+ param->testflag|=T_MEDIUM;
+ if (!(error= init_io_cache(¶m->read_cache, file->dfile,
my_default_record_cache_size, READ_CACHE,
share->pack.header_length, 1, MYF(MY_WME))))
{
- error= chk_data_link(¶m, file, test(param.testflag & T_EXTEND));
- end_io_cache(&(param.read_cache));
+ error= chk_data_link(param, file, test(param->testflag & T_EXTEND));
+ end_io_cache(&(param->read_cache));
}
- param.testflag= old_testflag;
+ param->testflag= old_testflag;
}
}
if (!error)
@@ -916,7 +916,7 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
if ((share->state.changed & (STATE_CHANGED |
STATE_CRASHED_ON_REPAIR |
STATE_CRASHED | STATE_NOT_ANALYZED)) ||
- (param.testflag & T_STATISTICS) ||
+ (param->testflag & T_STATISTICS) ||
mi_is_crashed(file))
{
file->update|=HA_STATE_CHANGED | HA_STATE_ROW_CHANGED;
@@ -924,7 +924,7 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
share->state.changed&= ~(STATE_CHANGED | STATE_CRASHED |
STATE_CRASHED_ON_REPAIR);
if (!(table->db_stat & HA_READ_ONLY))
- error=update_state_info(¶m,file,UPDATE_TIME | UPDATE_OPEN_COUNT |
+ error=update_state_info(param,file,UPDATE_TIME | UPDATE_OPEN_COUNT |
UPDATE_STAT);
mysql_mutex_unlock(&share->intern_lock);
info(HA_STATUS_NO_LOCK | HA_STATUS_TIME | HA_STATUS_VARIABLE |
@@ -951,30 +951,30 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt)
{
int error=0;
- HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param));
+ HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
MYISAM_SHARE* share = file->s;
- if (!¶m)
+ if (!param)
return HA_ADMIN_INTERNAL_ERROR;
- myisamchk_init(¶m);
- param.thd = thd;
- param.op_name= "analyze";
- param.db_name= table->s->db.str;
- param.table_name= table->alias.c_ptr();
- param.testflag= (T_FAST | T_CHECK | T_SILENT | T_STATISTICS |
+ myisamchk_init(param);
+ param->thd = thd;
+ param->op_name= "analyze";
+ param->db_name= table->s->db.str;
+ param->table_name= table->alias.c_ptr();
+ param->testflag= (T_FAST | T_CHECK | T_SILENT | T_STATISTICS |
T_DONT_CHECK_CHECKSUM);
- param.using_global_keycache = 1;
- param.stats_method= (enum_handler_stats_method)THDVAR(thd, stats_method);
+ param->using_global_keycache = 1;
+ param->stats_method= (enum_handler_stats_method)THDVAR(thd, stats_method);
if (!(share->state.changed & STATE_NOT_ANALYZED))
return HA_ADMIN_ALREADY_DONE;
- error = chk_key(¶m, file);
+ error = chk_key(param, file);
if (!error)
{
mysql_mutex_lock(&share->intern_lock);
- error=update_state_info(¶m,file,UPDATE_STAT);
+ error=update_state_info(param,file,UPDATE_STAT);
mysql_mutex_unlock(&share->intern_lock);
}
else if (!mi_is_crashed(file) && !thd->killed)
@@ -986,37 +986,37 @@ int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt)
int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt)
{
int error;
- HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param));
+ HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
ha_rows start_records;
- if (!file || !¶m) return HA_ADMIN_INTERNAL_ERROR;
+ if (!file || !param) return HA_ADMIN_INTERNAL_ERROR;
- myisamchk_init(¶m);
- param.thd = thd;
- param.op_name= "repair";
- param.testflag= ((check_opt->flags & ~(T_EXTEND)) |
+ myisamchk_init(param);
+ param->thd = thd;
+ param->op_name= "repair";
+ param->testflag= ((check_opt->flags & ~(T_EXTEND)) |
T_SILENT | T_FORCE_CREATE | T_CALC_CHECKSUM |
(check_opt->flags & T_EXTEND ? T_REP : T_REP_BY_SORT));
- param.sort_buffer_length= THDVAR(thd, sort_buffer_size);
- param.backup_time= check_opt->start_time;
+ param->sort_buffer_length= THDVAR(thd, sort_buffer_size);
+ param->backup_time= check_opt->start_time;
start_records=file->state->records;
- while ((error=repair(thd,param,0)) && param.retry_repair)
+ while ((error=repair(thd,*param,0)) && param->retry_repair)
{
- param.retry_repair=0;
- if (test_all_bits(param.testflag,
+ param->retry_repair=0;
+ if (test_all_bits(param->testflag,
(uint) (T_RETRY_WITHOUT_QUICK | T_QUICK)))
{
- param.testflag&= ~(T_RETRY_WITHOUT_QUICK | T_QUICK);
+ param->testflag&= ~(T_RETRY_WITHOUT_QUICK | T_QUICK);
/* Ensure we don't loose any rows when retrying without quick */
- param.testflag|= T_SAFE_REPAIR;
+ param->testflag|= T_SAFE_REPAIR;
sql_print_information("Retrying repair of: '%s' including modifying data file",
table->s->path.str);
continue;
}
- param.testflag&= ~T_QUICK;
- if ((param.testflag & T_REP_BY_SORT))
+ param->testflag&= ~T_QUICK;
+ if ((param->testflag & T_REP_BY_SORT))
{
- param.testflag= (param.testflag & ~T_REP_BY_SORT) | T_REP;
+ param->testflag= (param->testflag & ~T_REP_BY_SORT) | T_REP;
sql_print_information("Retrying repair of: '%s' with keycache",
table->s->path.str);
continue;
@@ -1038,22 +1038,22 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt)
int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt)
{
int error;
- HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param));
+ HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
- if (!file || !¶m) return HA_ADMIN_INTERNAL_ERROR;
+ if (!file || !param) return HA_ADMIN_INTERNAL_ERROR;
- myisamchk_init(¶m);
- param.thd = thd;
- param.op_name= "optimize";
- param.testflag= (check_opt->flags | T_SILENT | T_FORCE_CREATE |
+ myisamchk_init(param);
+ param->thd = thd;
+ param->op_name= "optimize";
+ param->testflag= (check_opt->flags | T_SILENT | T_FORCE_CREATE |
T_REP_BY_SORT | T_STATISTICS | T_SORT_INDEX);
- param.sort_buffer_length= THDVAR(thd, sort_buffer_size);
- if ((error= repair(thd,param,1)) && param.retry_repair)
+ param->sort_buffer_length= THDVAR(thd, sort_buffer_size);
+ if ((error= repair(thd,*param,1)) && param->retry_repair)
{
sql_print_warning("Warning: Optimize table got errno %d on %s.%s, retrying",
- my_errno, param.db_name, param.table_name);
- param.testflag&= ~T_REP_BY_SORT;
- error= repair(thd,param,1);
+ my_errno, param->db_name, param->table_name);
+ param->testflag&= ~T_REP_BY_SORT;
+ error= repair(thd,*param,1);
}
return error;
}
@@ -1253,17 +1253,17 @@ int ha_myisam::assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt)
if (error != HA_ADMIN_OK)
{
/* Send error to user */
- HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param));
- if (!¶m)
+ HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
+ if (!param)
return HA_ADMIN_INTERNAL_ERROR;
- myisamchk_init(¶m);
- param.thd= thd;
- param.op_name= "assign_to_keycache";
- param.db_name= table->s->db.str;
- param.table_name= table->s->table_name.str;
- param.testflag= 0;
- mi_check_print_error(¶m, errmsg);
+ myisamchk_init(param);
+ param->thd= thd;
+ param->op_name= "assign_to_keycache";
+ param->db_name= table->s->db.str;
+ param->table_name= table->s->table_name.str;
+ param->testflag= 0;
+ mi_check_print_error(param, errmsg);
}
DBUG_RETURN(error);
}
@@ -1320,16 +1320,16 @@ int ha_myisam::preload_keys(THD* thd, HA_CHECK_OPT *check_opt)
err:
{
- HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param));
- if (!¶m)
+ HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
+ if (!param)
return HA_ADMIN_INTERNAL_ERROR;
- myisamchk_init(¶m);
- param.thd= thd;
- param.op_name= "preload_keys";
- param.db_name= table->s->db.str;
- param.table_name= table->s->table_name.str;
- param.testflag= 0;
- mi_check_print_error(¶m, errmsg);
+ myisamchk_init(param);
+ param->thd= thd;
+ param->op_name= "preload_keys";
+ param->db_name= table->s->db.str;
+ param->table_name= table->s->table_name.str;
+ param->testflag= 0;
+ mi_check_print_error(param, errmsg);
DBUG_RETURN(error);
}
}
@@ -1434,42 +1434,42 @@ int ha_myisam::enable_indexes(uint mode)
{
THD *thd= table->in_use;
int was_error= thd->is_error();
- HA_CHECK ¶m= *(HA_CHECK*) thd->alloc(sizeof(param));
+ HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param);
const char *save_proc_info=thd->proc_info;
- if (!¶m)
+ if (!param)
DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR);
thd_proc_info(thd, "Creating index");
- myisamchk_init(¶m);
- param.op_name= "recreating_index";
- param.testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK |
+ myisamchk_init(param);
+ param->op_name= "recreating_index";
+ param->testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK |
T_CREATE_MISSING_KEYS);
/*
Don't lock and unlock table if it's locked.
Normally table should be locked. This test is mostly for safety.
*/
if (likely(file->lock_type != F_UNLCK))
- param.testflag|= T_NO_LOCKS;
+ param->testflag|= T_NO_LOCKS;
- param.myf_rw&= ~MY_WAIT_IF_FULL;
- param.sort_buffer_length= THDVAR(thd, sort_buffer_size);
- param.stats_method= (enum_handler_stats_method)THDVAR(thd, stats_method);
- param.tmpdir=&mysql_tmpdir_list;
- if ((error= (repair(thd,param,0) != HA_ADMIN_OK)) && param.retry_repair)
+ param->myf_rw&= ~MY_WAIT_IF_FULL;
+ param->sort_buffer_length= THDVAR(thd, sort_buffer_size);
+ param->stats_method= (enum_handler_stats_method)THDVAR(thd, stats_method);
+ param->tmpdir=&mysql_tmpdir_list;
+ if ((error= (repair(thd,*param,0) != HA_ADMIN_OK)) && param->retry_repair)
{
sql_print_warning("Warning: Enabling keys got errno %d on %s.%s, retrying",
- my_errno, param.db_name, param.table_name);
+ my_errno, param->db_name, param->table_name);
/*
Repairing by sort failed. Now try standard repair method.
Still we want to fix only index file. If data file corruption
was detected (T_RETRY_WITHOUT_QUICK), we shouldn't do much here.
Let implicit repair do this job.
*/
- if (!(param.testflag & T_RETRY_WITHOUT_QUICK))
+ if (!(param->testflag & T_RETRY_WITHOUT_QUICK))
{
- param.testflag&= ~T_REP_BY_SORT;
- error= (repair(thd,param,0) != HA_ADMIN_OK);
+ param->testflag&= ~T_REP_BY_SORT;
+ error= (repair(thd,*param,0) != HA_ADMIN_OK);
}
/*
If the standard repair succeeded, clear all error messages which
From 1fd3cc8c1f2bfe052c0d6672d65b6d0ac1c87e0f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?=
Date: Wed, 8 Mar 2017 10:06:34 +0200
Subject: [PATCH 145/226] Fix a compiler warning.
---
storage/innobase/dict/dict0load.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/storage/innobase/dict/dict0load.c b/storage/innobase/dict/dict0load.c
index d7168b6e4bbf6..079103289526f 100644
--- a/storage/innobase/dict/dict0load.c
+++ b/storage/innobase/dict/dict0load.c
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2013, Innobase Oy. All Rights Reserved.
+Copyright (c) 2017, 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
@@ -1838,7 +1839,7 @@ dict_load_table(
if (!fil_open_single_table_tablespace(
TRUE, table->space,
table->flags == DICT_TF_COMPACT ? 0 :
- table->flags & ~(~0 << DICT_TF_BITS), name)) {
+ table->flags & ~(~0U << DICT_TF_BITS), name)) {
/* We failed to find a sensible
tablespace file */
From 9c47beb8bd7e60f00e434d8c1e4bbf2b0befb28c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?=
Date: Wed, 8 Mar 2017 10:07:50 +0200
Subject: [PATCH 146/226] MDEV-11027 InnoDB log recovery is too noisy
Provide more useful progress reporting of crash recovery.
recv_sys_t::progress_time: The time of the last report.
recv_scan_print_counter: Remove.
log_group_read_log_seg(): After after each I/O request,
report progress if needed.
recv_apply_hashed_log_recs(): At the start of each batch,
if there are pages to be recovered, issue a message.
---
storage/innobase/include/log0recv.h | 3 +
storage/innobase/log/log0log.c | 11 +++
storage/innobase/log/log0recv.c | 105 +++++++-------------------
storage/xtradb/include/log0recv.h | 3 +
storage/xtradb/log/log0log.c | 11 +++
storage/xtradb/log/log0recv.c | 113 ++++++++--------------------
6 files changed, 90 insertions(+), 156 deletions(-)
diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h
index ec70e4b7d5631..aa5f79aa19881 100644
--- a/storage/innobase/include/log0recv.h
+++ b/storage/innobase/include/log0recv.h
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1997, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 2017, 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
@@ -428,6 +429,8 @@ struct recv_sys_struct{
scan find a corrupt log block, or a corrupt
log record, or there is a log parsing
buffer overflow */
+ /** the time when progress was last reported */
+ ib_time_t progress_time;
#ifdef UNIV_LOG_ARCHIVE
log_group_t* archive_group;
/*!< in archive recovery: the log group whose
diff --git a/storage/innobase/log/log0log.c b/storage/innobase/log/log0log.c
index eacee12a2d4cb..4a307c8059892 100644
--- a/storage/innobase/log/log0log.c
+++ b/storage/innobase/log/log0log.c
@@ -2,6 +2,7 @@
Copyright (c) 1995, 2010, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Google Inc.
+Copyright (c) 2017, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -2303,6 +2304,7 @@ log_group_read_log_seg(
ulint len;
ulint source_offset;
ibool sync;
+ ib_time_t time;
ut_ad(mutex_own(&(log_sys->mutex)));
@@ -2335,6 +2337,15 @@ log_group_read_log_seg(
start_lsn += len;
buf += len;
+ time = ut_time();
+
+ if (recv_sys->progress_time - time >= 15) {
+ recv_sys->progress_time = time;
+ ut_print_timestamp(stderr);
+ fprintf(stderr, " InnoDB: Read redo log up to LSN=%llu\n",
+ start_lsn);
+ }
+
if (start_lsn != end_lsn) {
goto loop;
diff --git a/storage/innobase/log/log0recv.c b/storage/innobase/log/log0recv.c
index eee3b9ff6c371..a458e47d45d68 100644
--- a/storage/innobase/log/log0recv.c
+++ b/storage/innobase/log/log0recv.c
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, 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
@@ -65,7 +66,7 @@ this must be less than UNIV_PAGE_SIZE as it is stored in the buffer pool */
#define RECV_READ_AHEAD_AREA 32
/** The recovery system */
-UNIV_INTERN recv_sys_t* recv_sys = NULL;
+UNIV_INTERN recv_sys_t* recv_sys;
/** TRUE when applying redo log records during crash recovery; FALSE
otherwise. Note that this is FALSE while a background thread is
rolling back incomplete transactions. */
@@ -121,9 +122,6 @@ UNIV_INTERN ibool recv_is_making_a_backup = FALSE;
UNIV_INTERN ibool recv_is_from_backup = FALSE;
# define buf_pool_get_curr_size() (5 * 1024 * 1024)
#endif /* !UNIV_HOTBACKUP */
-/** The following counter is used to decide when to print info on
-log scan */
-static ulint recv_scan_print_counter;
/** The type of the previous parsed redo log record */
static ulint recv_previous_parsed_rec_type;
@@ -275,8 +273,6 @@ recv_sys_var_init(void)
recv_no_ibuf_operations = FALSE;
- recv_scan_print_counter = 0;
-
recv_previous_parsed_rec_type = 999999;
recv_previous_parsed_rec_offset = 0;
@@ -342,6 +338,7 @@ recv_sys_init(
recv_sys->last_block = ut_align(recv_sys->last_block_buf_start,
OS_FILE_LOG_BLOCK_SIZE);
recv_sys->found_corrupt_log = FALSE;
+ recv_sys->progress_time = ut_time();
recv_max_page_lsn = 0;
@@ -1490,6 +1487,7 @@ recv_recover_page_func(
ibool success;
#endif /* !UNIV_HOTBACKUP */
mtr_t mtr;
+ ib_time_t time;
mutex_enter(&(recv_sys->mutex));
@@ -1669,6 +1667,8 @@ recv_recover_page_func(
mtr_commit(&mtr);
+ time = ut_time();
+
mutex_enter(&(recv_sys->mutex));
if (recv_max_page_lsn < page_lsn) {
@@ -1677,11 +1677,16 @@ recv_recover_page_func(
recv_addr->state = RECV_PROCESSED;
- ut_a(recv_sys->n_addrs);
- recv_sys->n_addrs--;
-
- mutex_exit(&(recv_sys->mutex));
+ ut_a(recv_sys->n_addrs > 0);
+ if (--recv_sys->n_addrs && recv_sys->progress_time - time >= 15) {
+ recv_sys->progress_time = time;
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: To recover: " ULINTPF " pages from log\n",
+ recv_sys->n_addrs);
+ }
+ mutex_exit(&recv_sys->mutex);
}
#ifndef UNIV_HOTBACKUP
@@ -1727,9 +1732,6 @@ recv_read_in_area(
}
buf_read_recv_pages(FALSE, space, zip_size, page_nos, n);
- /*
- fprintf(stderr, "Recv pages at %lu n %lu\n", page_nos[0], n);
- */
return(n);
}
@@ -1753,7 +1755,6 @@ recv_apply_hashed_log_recs(
recv_addr_t* recv_addr;
ulint i;
ulint n_pages;
- ibool has_printed = FALSE;
mtr_t mtr;
loop:
mutex_enter(&(recv_sys->mutex));
@@ -1773,6 +1774,16 @@ recv_apply_hashed_log_recs(
recv_no_ibuf_operations = TRUE;
}
+ if (recv_sys->n_addrs) {
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: %s" ULINTPF " pages from redo log\n",
+ allow_ibuf
+ ? "Starting final batch to recover "
+ : "Starting a batch to recover ",
+ recv_sys->n_addrs);
+ }
+
recv_sys->apply_log_recs = TRUE;
recv_sys->apply_batch_on = TRUE;
@@ -1786,16 +1797,6 @@ recv_apply_hashed_log_recs(
ulint page_no = recv_addr->page_no;
if (recv_addr->state == RECV_NOT_PROCESSED) {
- if (!has_printed) {
- ut_print_timestamp(stderr);
- fputs(" InnoDB: Starting an"
- " apply batch of log records"
- " to the database...\n"
- "InnoDB: Progress in percents: ",
- stderr);
- has_printed = TRUE;
- }
-
mutex_exit(&(recv_sys->mutex));
if (buf_page_peek(space, page_no)) {
@@ -1821,16 +1822,6 @@ recv_apply_hashed_log_recs(
recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
}
-
- if (has_printed
- && (i * 100) / hash_get_n_cells(recv_sys->addr_hash)
- != ((i + 1) * 100)
- / hash_get_n_cells(recv_sys->addr_hash)) {
-
- fprintf(stderr, "%lu ", (ulong)
- ((i * 100)
- / hash_get_n_cells(recv_sys->addr_hash)));
- }
}
/* Wait until all the pages have been processed */
@@ -1844,11 +1835,6 @@ recv_apply_hashed_log_recs(
mutex_enter(&(recv_sys->mutex));
}
- if (has_printed) {
-
- fprintf(stderr, "\n");
- }
-
if (!allow_ibuf) {
/* Flush all the file pages to disk and invalidate them in
the buffer pool */
@@ -1876,10 +1862,6 @@ recv_apply_hashed_log_recs(
recv_sys_empty_hash();
- if (has_printed) {
- fprintf(stderr, "InnoDB: Apply batch completed\n");
- }
-
mutex_exit(&(recv_sys->mutex));
}
#else /* !UNIV_HOTBACKUP */
@@ -1903,10 +1885,6 @@ recv_apply_log_recs_for_backup(void)
block = back_block1;
- fputs("InnoDB: Starting an apply batch of log records"
- " to the database...\n"
- "InnoDB: Progress in percents: ", stderr);
-
n_hash_cells = hash_get_n_cells(recv_sys->addr_hash);
for (i = 0; i < n_hash_cells; i++) {
@@ -2697,10 +2675,10 @@ recv_scan_log_recs(
#ifndef UNIV_HOTBACKUP
if (recv_log_scan_is_startup_type
&& !recv_needed_recovery) {
-
+ ut_print_timestamp(stderr);
fprintf(stderr,
- "InnoDB: Log scan progressed"
- " past the checkpoint lsn %llu\n",
+ " InnoDB: Starting crash recovery"
+ " from checkpoint LSN=%llu\n",
recv_sys->scanned_lsn);
recv_init_crash_recovery();
}
@@ -2751,19 +2729,6 @@ recv_scan_log_recs(
*group_scanned_lsn = scanned_lsn;
- if (recv_needed_recovery
- || (recv_is_from_backup && !recv_is_making_a_backup)) {
- recv_scan_print_counter++;
-
- if (finished || (recv_scan_print_counter % 80 == 0)) {
-
- fprintf(stderr,
- "InnoDB: Doing recovery: scanned up to"
- " log sequence number %llu\n",
- *group_scanned_lsn);
- }
- }
-
if (more_data && !recv_sys->found_corrupt_log) {
/* Try to parse more log records */
@@ -2854,17 +2819,6 @@ recv_init_crash_recovery(void)
recv_needed_recovery = TRUE;
- ut_print_timestamp(stderr);
-
- fprintf(stderr,
- " InnoDB: Database was not"
- " shut down normally!\n"
- "InnoDB: Starting crash recovery.\n");
-
- fprintf(stderr,
- "InnoDB: Reading tablespace information"
- " from the .ibd files...\n");
-
fil_load_single_table_tablespaces();
/* If we are using the doublewrite method, we will
@@ -2877,8 +2831,7 @@ recv_init_crash_recovery(void)
fprintf(stderr,
"InnoDB: Restoring possible"
" half-written data pages from"
- " the doublewrite\n"
- "InnoDB: buffer...\n");
+ " the doublewrite buffer...\n");
trx_sys_doublewrite_init_or_restore_pages(TRUE);
}
}
diff --git a/storage/xtradb/include/log0recv.h b/storage/xtradb/include/log0recv.h
index ad30f6862c299..afac0d4f4ab1b 100644
--- a/storage/xtradb/include/log0recv.h
+++ b/storage/xtradb/include/log0recv.h
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1997, 2010, Innobase Oy. All Rights Reserved.
+Copyright (c) 2017, 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
@@ -465,6 +466,8 @@ struct recv_sys_struct{
scan find a corrupt log block, or a corrupt
log record, or there is a log parsing
buffer overflow */
+ /** the time when progress was last reported */
+ ib_time_t progress_time;
#ifdef UNIV_LOG_ARCHIVE
log_group_t* archive_group;
/*!< in archive recovery: the log group whose
diff --git a/storage/xtradb/log/log0log.c b/storage/xtradb/log/log0log.c
index e5063e9c8a100..e327fa7ea9a6a 100644
--- a/storage/xtradb/log/log0log.c
+++ b/storage/xtradb/log/log0log.c
@@ -2,6 +2,7 @@
Copyright (c) 1995, 2010, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2009, Google Inc.
+Copyright (c) 2017, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -2502,6 +2503,7 @@ log_group_read_log_seg(
ulint len;
ulint source_offset;
ibool sync;
+ ib_time_t time;
ut_ad(mutex_own(&(log_sys->mutex)));
@@ -2538,6 +2540,15 @@ log_group_read_log_seg(
start_lsn += len;
buf += len;
+ time = ut_time();
+
+ if (recv_sys->progress_time - time >= 15) {
+ recv_sys->progress_time = time;
+ ut_print_timestamp(stderr);
+ fprintf(stderr, " InnoDB: Read redo log up to LSN=%llu\n",
+ start_lsn);
+ }
+
if (start_lsn != end_lsn) {
if (release_mutex) {
diff --git a/storage/xtradb/log/log0recv.c b/storage/xtradb/log/log0recv.c
index aea83c9087023..6fdc3aff7cc90 100644
--- a/storage/xtradb/log/log0recv.c
+++ b/storage/xtradb/log/log0recv.c
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2017, 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
@@ -72,7 +73,7 @@ this must be less than UNIV_PAGE_SIZE as it is stored in the buffer pool */
#define RECV_READ_AHEAD_AREA 32
/** The recovery system */
-UNIV_INTERN recv_sys_t* recv_sys = NULL;
+UNIV_INTERN recv_sys_t* recv_sys;
/** TRUE when applying redo log records during crash recovery; FALSE
otherwise. Note that this is FALSE while a background thread is
rolling back incomplete transactions. */
@@ -128,9 +129,6 @@ UNIV_INTERN ibool recv_is_making_a_backup = FALSE;
UNIV_INTERN ibool recv_is_from_backup = FALSE;
# define buf_pool_get_curr_size() (5 * 1024 * 1024)
#endif /* !UNIV_HOTBACKUP */
-/** The following counter is used to decide when to print info on
-log scan */
-static ulint recv_scan_print_counter;
/** The type of the previous parsed redo log record */
static ulint recv_previous_parsed_rec_type;
@@ -285,8 +283,6 @@ recv_sys_var_init(void)
recv_no_ibuf_operations = FALSE;
- recv_scan_print_counter = 0;
-
recv_previous_parsed_rec_type = 999999;
recv_previous_parsed_rec_offset = 0;
@@ -357,6 +353,7 @@ recv_sys_init(
recv_sys->last_block = ut_align(recv_sys->last_block_buf_start,
OS_FILE_LOG_BLOCK_SIZE);
recv_sys->found_corrupt_log = FALSE;
+ recv_sys->progress_time = ut_time();
recv_max_page_lsn = 0;
@@ -1557,6 +1554,7 @@ recv_recover_page_func(
ibool success;
#endif /* !UNIV_HOTBACKUP */
mtr_t mtr;
+ ib_time_t time;
mutex_enter(&(recv_sys->mutex));
@@ -1769,6 +1767,8 @@ recv_recover_page_func(
mtr_commit(&mtr);
+ time = ut_time();
+
mutex_enter(&(recv_sys->mutex));
if (recv_max_page_lsn < page_lsn) {
@@ -1777,11 +1777,16 @@ recv_recover_page_func(
recv_addr->state = RECV_PROCESSED;
- ut_a(recv_sys->n_addrs);
- recv_sys->n_addrs--;
-
- mutex_exit(&(recv_sys->mutex));
+ ut_a(recv_sys->n_addrs > 0);
+ if (--recv_sys->n_addrs && recv_sys->progress_time - time >= 15) {
+ recv_sys->progress_time = time;
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: To recover: " ULINTPF " pages from log\n",
+ recv_sys->n_addrs);
+ }
+ mutex_exit(&recv_sys->mutex);
}
#ifndef UNIV_HOTBACKUP
@@ -1834,9 +1839,6 @@ recv_read_in_area(
}
buf_read_recv_pages(FALSE, space, zip_size, page_nos, n);
- /*
- fprintf(stderr, "Recv pages at %lu n %lu\n", page_nos[0], n);
- */
return(n);
}
@@ -1860,7 +1862,6 @@ recv_apply_hashed_log_recs(
recv_addr_t* recv_addr;
ulint i;
ulint n_pages;
- ibool has_printed = FALSE;
mtr_t mtr;
loop:
mutex_enter(&(recv_sys->mutex));
@@ -1880,6 +1881,20 @@ recv_apply_hashed_log_recs(
recv_no_ibuf_operations = TRUE;
}
+ if (recv_sys->n_addrs) {
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: %s" ULINTPF " pages from redo log\n",
+ allow_ibuf
+ ? "Starting final batch to recover "
+ : "Starting a batch to recover ",
+ recv_sys->n_addrs);
+
+ if (srv_recovery_stats) {
+ recv_sys->stats_recv_turns++;
+ }
+ }
+
recv_sys->apply_log_recs = TRUE;
recv_sys->apply_batch_on = TRUE;
@@ -1893,16 +1908,6 @@ recv_apply_hashed_log_recs(
ulint page_no = recv_addr->page_no;
if (recv_addr->state == RECV_NOT_PROCESSED) {
- if (!has_printed) {
- ut_print_timestamp(stderr);
- fputs(" InnoDB: Starting an"
- " apply batch of log records"
- " to the database...\n"
- "InnoDB: Progress in percents: ",
- stderr);
- has_printed = TRUE;
- }
-
mutex_exit(&(recv_sys->mutex));
if (buf_page_peek(space, page_no)) {
@@ -1928,16 +1933,6 @@ recv_apply_hashed_log_recs(
recv_addr = HASH_GET_NEXT(addr_hash, recv_addr);
}
-
- if (has_printed
- && (i * 100) / hash_get_n_cells(recv_sys->addr_hash)
- != ((i + 1) * 100)
- / hash_get_n_cells(recv_sys->addr_hash)) {
-
- fprintf(stderr, "%lu ", (ulong)
- ((i * 100)
- / hash_get_n_cells(recv_sys->addr_hash)));
- }
}
/* Wait until all the pages have been processed */
@@ -1951,11 +1946,6 @@ recv_apply_hashed_log_recs(
mutex_enter(&(recv_sys->mutex));
}
- if (has_printed) {
-
- fprintf(stderr, "\n");
- }
-
if (!allow_ibuf) {
/* Flush all the file pages to disk and invalidate them in
the buffer pool */
@@ -1983,14 +1973,6 @@ recv_apply_hashed_log_recs(
recv_sys_empty_hash();
- if (has_printed) {
- fprintf(stderr, "InnoDB: Apply batch completed\n");
-
- if (srv_recovery_stats) {
- recv_sys->stats_recv_turns++;
- }
- }
-
mutex_exit(&(recv_sys->mutex));
}
#else /* !UNIV_HOTBACKUP */
@@ -2014,10 +1996,6 @@ recv_apply_log_recs_for_backup(void)
block = back_block1;
- fputs("InnoDB: Starting an apply batch of log records"
- " to the database...\n"
- "InnoDB: Progress in percents: ", stderr);
-
n_hash_cells = hash_get_n_cells(recv_sys->addr_hash);
for (i = 0; i < n_hash_cells; i++) {
@@ -2808,10 +2786,10 @@ recv_scan_log_recs(
#ifndef UNIV_HOTBACKUP
if (recv_log_scan_is_startup_type
&& !recv_needed_recovery) {
-
+ ut_print_timestamp(stderr);
fprintf(stderr,
- "InnoDB: Log scan progressed"
- " past the checkpoint lsn %llu\n",
+ " InnoDB: Starting crash recovery"
+ " from checkpoint LSN=%llu\n",
recv_sys->scanned_lsn);
recv_init_crash_recovery();
}
@@ -2862,19 +2840,6 @@ recv_scan_log_recs(
*group_scanned_lsn = scanned_lsn;
- if (recv_needed_recovery
- || (recv_is_from_backup && !recv_is_making_a_backup)) {
- recv_scan_print_counter++;
-
- if (finished || (recv_scan_print_counter % 80 == 0)) {
-
- fprintf(stderr,
- "InnoDB: Doing recovery: scanned up to"
- " log sequence number %llu\n",
- *group_scanned_lsn);
- }
- }
-
if (more_data && !recv_sys->found_corrupt_log) {
/* Try to parse more log records */
@@ -2965,17 +2930,6 @@ recv_init_crash_recovery(void)
recv_needed_recovery = TRUE;
- ut_print_timestamp(stderr);
-
- fprintf(stderr,
- " InnoDB: Database was not"
- " shut down normally!\n"
- "InnoDB: Starting crash recovery.\n");
-
- fprintf(stderr,
- "InnoDB: Reading tablespace information"
- " from the .ibd files...\n");
-
fil_load_single_table_tablespaces();
/* If we are using the doublewrite method, we will
@@ -2988,8 +2942,7 @@ recv_init_crash_recovery(void)
fprintf(stderr,
"InnoDB: Restoring possible"
" half-written data pages from"
- " the doublewrite\n"
- "InnoDB: buffer...\n");
+ " the doublewrite buffer...\n");
trx_sys_doublewrite_init_or_restore_pages(TRUE);
}
}
From 6860a4b55664d8fc53636906240c089417e1849d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?=
Date: Wed, 8 Mar 2017 10:31:06 +0200
Subject: [PATCH 147/226] MDEV-12206 Query_cache::send_result_to_client() may
corrupt THD::query_plan_flags
This is essentially a backport of the 10.0
commit 203f4d41930a140d469aeca9840a7b226afeaaf6
that fixes a bug and silences a GCC 6.3.0 warning
about a left shift of a signed integer.
Missing parenthesis in a macro definition caused wrong operation
in the Query_cache::send_result_to_client() statement
thd->query_plan_flags= (thd->query_plan_flags & ~QPLAN_QC_NO) | QPLAN_QC;
This would expand to
thd->query_plan_flags= (thd->query_plan_flags & ~1) << 6 | 1 << 5;
which would shift the flags by 6 and clear an unrelated flag, instead
of clearing the flag (1 << 6).
---
sql/log_slow.h | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/sql/log_slow.h b/sql/log_slow.h
index 92a2d1bf4f64d..541ef55f9e1d7 100644
--- a/sql/log_slow.h
+++ b/sql/log_slow.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2009 Monty Program Ab
+/* Copyright (C) 2009, 2017, 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
@@ -16,20 +16,19 @@
/* Defining what to log to slow log */
#define LOG_SLOW_VERBOSITY_INIT 0
-#define LOG_SLOW_VERBOSITY_INNODB 1 << 0
-#define LOG_SLOW_VERBOSITY_QUERY_PLAN 1 << 1
+#define LOG_SLOW_VERBOSITY_INNODB (1U << 0)
+#define LOG_SLOW_VERBOSITY_QUERY_PLAN (1U << 1)
#define QPLAN_INIT QPLAN_QC_NO
-#define QPLAN_ADMIN 1 << 0
-#define QPLAN_FILESORT 1 << 1
-#define QPLAN_FILESORT_DISK 1 << 2
-#define QPLAN_FULL_JOIN 1 << 3
-#define QPLAN_FULL_SCAN 1 << 4
-#define QPLAN_QC 1 << 5
-#define QPLAN_QC_NO 1 << 6
-#define QPLAN_TMP_DISK 1 << 7
-#define QPLAN_TMP_TABLE 1 << 8
+#define QPLAN_ADMIN (1U << 0)
+#define QPLAN_FILESORT (1U << 1)
+#define QPLAN_FILESORT_DISK (1U << 2)
+#define QPLAN_FULL_JOIN (1U << 3)
+#define QPLAN_FULL_SCAN (1U << 4)
+#define QPLAN_QC (1U << 5)
+#define QPLAN_QC_NO (1U << 6)
+#define QPLAN_TMP_DISK (1U << 7)
+#define QPLAN_TMP_TABLE (1U << 8)
/* ... */
-#define QPLAN_MAX ((ulong) 1) << 31 /* reserved as placeholder */
-
+#define QPLAN_MAX (1U << 31) /* reserved as placeholder */
From 74fe0e03d554130b60bf734531d1763451e6ceff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?=
Date: Wed, 8 Mar 2017 11:46:34 +0200
Subject: [PATCH 148/226] Remove unused declarations.
---
storage/innobase/sync/sync0sync.cc | 5 +----
storage/xtradb/srv/srv0start.cc | 2 --
storage/xtradb/sync/sync0sync.cc | 5 +----
3 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/storage/innobase/sync/sync0sync.cc b/storage/innobase/sync/sync0sync.cc
index df360d221daf6..a2165a917b8b0 100644
--- a/storage/innobase/sync/sync0sync.cc
+++ b/storage/innobase/sync/sync0sync.cc
@@ -2,7 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
-Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -223,9 +223,6 @@ UNIV_INTERN mysql_pfs_key_t mutex_list_mutex_key;
/** Latching order checks start when this is set TRUE */
UNIV_INTERN ibool sync_order_checks_on = FALSE;
-/** Number of slots reserved for each OS thread in the sync level array */
-static const ulint SYNC_THREAD_N_LEVELS = 10000;
-
/** Array for tracking sync levels per thread. */
typedef std::vector sync_arr_t;
diff --git a/storage/xtradb/srv/srv0start.cc b/storage/xtradb/srv/srv0start.cc
index 5bd2b861ea04a..d94dfe87783fe 100644
--- a/storage/xtradb/srv/srv0start.cc
+++ b/storage/xtradb/srv/srv0start.cc
@@ -2410,8 +2410,6 @@ innobase_start_or_create_for_mysql(void)
trx_sys_create();
- bool srv_monitor_thread_started = false;
-
if (create_new_db) {
ut_a(!srv_read_only_mode);
init_log_online();
diff --git a/storage/xtradb/sync/sync0sync.cc b/storage/xtradb/sync/sync0sync.cc
index ca937df4475df..c270b73e5a0f9 100644
--- a/storage/xtradb/sync/sync0sync.cc
+++ b/storage/xtradb/sync/sync0sync.cc
@@ -2,7 +2,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
-Copyright (c) 2017, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2017, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -224,9 +224,6 @@ UNIV_INTERN mysql_pfs_key_t mutex_list_mutex_key;
/** Latching order checks start when this is set TRUE */
UNIV_INTERN ibool sync_order_checks_on = FALSE;
-/** Number of slots reserved for each OS thread in the sync level array */
-static const ulint SYNC_THREAD_N_LEVELS = 10000;
-
/** Array for tracking sync levels per thread. */
typedef std::vector sync_arr_t;
From f65c9f825d164cf79dd6d5897ef144abba40ff6d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?=
Date: Tue, 7 Mar 2017 15:52:17 +0200
Subject: [PATCH 149/226] mysql_client_test_nonblock fails when compiled with
clang
mysql_client uses some inline assembly code to switch thread stacks.
This works, however tools that perform backtrace get confused to fix
this we write a specific constant to signify bottom of stack. This
constant is needed when compiling with CLang as well.
---
mysys/my_context.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mysys/my_context.c b/mysys/my_context.c
index 5ddb2ccd566d6..6960b0c6c5a38 100644
--- a/mysys/my_context.c
+++ b/mysys/my_context.c
@@ -206,7 +206,8 @@ my_context_spawn(struct my_context *c, void (*f)(void *), void *d)
(
"movq %%rsp, (%[save])\n\t"
"movq %[stack], %%rsp\n\t"
-#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) && !defined(__INTEL_COMPILER)
+#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) || __clang__) && \
+ !defined(__INTEL_COMPILER)
/*
This emits a DWARF DW_CFA_undefined directive to make the return address
undefined. This indicates that this is the top of the stack frame, and
From 65ef8ec8aafc09c4bee91e170aa2a9c0e0668a8f Mon Sep 17 00:00:00 2001
From: Vladislav Vaintroub
Date: Wed, 8 Mar 2017 11:12:12 +0000
Subject: [PATCH 150/226] MDEV-12207 Include windows compatibility manifest
into executable to make GetVersionEx work correctly
---
cmake/mysql_add_executable.cmake | 8 ++++++++
cmake/win_compatibility.manifest | 22 ++++++++++++++++++++++
2 files changed, 30 insertions(+)
create mode 100644 cmake/win_compatibility.manifest
diff --git a/cmake/mysql_add_executable.cmake b/cmake/mysql_add_executable.cmake
index 0c93fb179f5fd..45575bdd53656 100644
--- a/cmake/mysql_add_executable.cmake
+++ b/cmake/mysql_add_executable.cmake
@@ -38,6 +38,14 @@ FUNCTION (MYSQL_ADD_EXECUTABLE)
SET(sources ${ARG_DEFAULT_ARGS})
ADD_VERSION_INFO(${target} EXECUTABLE sources)
+
+ IF(MSVC)
+ # Add compatibility manifest, to fix GetVersionEx on Windows 8.1 and later
+ IF (CMAKE_VERSION VERSION_GREATER 3.3)
+ SET(sources ${sources} ${PROJECT_SOURCE_DIR}/cmake/win_compatibility.manifest)
+ ENDIF()
+ ENDIF()
+
ADD_EXECUTABLE(${target} ${ARG_WIN32} ${ARG_MACOSX_BUNDLE} ${ARG_EXCLUDE_FROM_ALL} ${sources})
# tell CPack where to install
IF(NOT ARG_EXCLUDE_FROM_ALL)
diff --git a/cmake/win_compatibility.manifest b/cmake/win_compatibility.manifest
new file mode 100644
index 0000000000000..2e4b27a6dc4c5
--- /dev/null
+++ b/cmake/win_compatibility.manifest
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From e1e04c3d681eee64e4b4e219cd89a64a84d43976 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?=
Date: Wed, 8 Mar 2017 14:40:02 +0200
Subject: [PATCH 151/226] Correct a merge error.
---
mysql-test/t/subselect_innodb.test | 54 ++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/mysql-test/t/subselect_innodb.test b/mysql-test/t/subselect_innodb.test
index 384464a9b7a39..b26c5036f3fd4 100644
--- a/mysql-test/t/subselect_innodb.test
+++ b/mysql-test/t/subselect_innodb.test
@@ -501,3 +501,57 @@ SELECT * FROM v1, t2 WHERE ( f1, f2 ) IN ( SELECT f1, f1 FROM t1 );
set join_cache_level = default;
drop view v1;
drop table t1,t2;
+
+--echo #
+--echo # MDEV-6041: ORDER BY+subqueries: subquery_table.key=outer_table.col is not recongized as binding
+--echo #
+create table t1(a int) engine=innodb;
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t2(
+ id int primary key,
+ key1 int,
+ col1 int,
+ key(key1)
+) engine=innodb;
+
+insert into t2
+ select
+ A.a + B.a*10 + C.a*100 + D.a* 1000,
+ A.a + 10*B.a,
+ 123456
+from t1 A, t1 B, t1 C, t1 D;
+
+--echo # Table tsubq:
+--echo # - must use 'ref' (not 'index'), and must not use 'Using filesort'
+--echo # - shows a bad estimate for 'rows' (but I'm not sure if one can do better w/o histograms)
+explain select
+ (SELECT
+ concat(id, '-', key1, '-', col1)
+ FROM t2
+ WHERE t2.key1 = t1.a
+ ORDER BY t2.id ASC LIMIT 1)
+from
+ t1;
+
+--echo #
+--echo # MDEV-6081: ORDER BY+ref(const): selectivity is very incorrect (MySQL Bug#14338686)
+--echo #
+
+alter table t2 add key2 int;
+update t2 set key2=key1;
+alter table t2 add key(key2);
+analyze table t2;
+flush tables;
+--echo # Table tsubq must use 'ref' + Using filesort (not 'index' w/o filesort)
+--replace_column 9 #
+explain select
+ (SELECT
+ concat(id, '-', key1, '-', col1)
+ FROM t2
+ WHERE t2.key1 = t1.a
+ ORDER BY t2.key2 ASC LIMIT 1)
+from
+ t1;
+
+drop table t1,t2;
From bb4ef470c24cdbcedba3dd3dcda3b3d88b6fb491 Mon Sep 17 00:00:00 2001
From: iangilfillan
Date: Wed, 8 Mar 2017 17:35:55 +0200
Subject: [PATCH 152/226] Minor wording fix in mysqladmin man page
---
man/mysqladmin.1 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/man/mysqladmin.1 b/man/mysqladmin.1
index d974f569f1a54..d1fdfd9d5aae4 100644
--- a/man/mysqladmin.1
+++ b/man/mysqladmin.1
@@ -821,7 +821,7 @@ Connect to the MariaDB server on the given host\&.
\fB\-\-local\fR,
\fB\-l\fR
.sp
-Suppress the SQL command(s) from being written to the binary log by enabled sql_log_bin=0 for the session\&.
+Suppress the SQL command(s) from being written to the binary log by enabling sql_log_bin=0 for the session\&.
.RE
.sp
.RS 4
From 9fe92a9770a801c4cd36390620486be4cb06752b Mon Sep 17 00:00:00 2001
From: Daniel Bartholomew
Date: Wed, 8 Mar 2017 11:13:34 -0500
Subject: [PATCH 153/226] bump the VERSION
---
VERSION | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/VERSION b/VERSION
index 5f666b9a57db0..22d7ed0a90385 100644
--- a/VERSION
+++ b/VERSION
@@ -1,3 +1,3 @@
MYSQL_VERSION_MAJOR=10
MYSQL_VERSION_MINOR=0
-MYSQL_VERSION_PATCH=30
+MYSQL_VERSION_PATCH=31
From 498f4a825b29a37cb27f1c76741987de8c510d06 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?=
Date: Thu, 9 Mar 2017 08:54:07 +0200
Subject: [PATCH 154/226] Fix InnoDB/XtraDB compilation warnings on 32-bit
builds.
---
extra/innochecksum.cc | 3 ++-
storage/innobase/buf/buf0buf.cc | 3 ++-
storage/innobase/fil/fil0crypt.cc | 11 +++++----
storage/innobase/lock/lock0lock.cc | 13 +++++++----
storage/innobase/log/log0crypt.cc | 6 +++--
storage/innobase/os/os0file.cc | 36 ++++++++++++++++-------------
storage/innobase/row/row0import.cc | 6 ++---
storage/innobase/row/row0merge.cc | 6 ++---
storage/xtradb/buf/buf0buf.cc | 3 ++-
storage/xtradb/fil/fil0crypt.cc | 11 +++++----
storage/xtradb/lock/lock0lock.cc | 13 +++++++----
storage/xtradb/log/log0crypt.cc | 6 +++--
storage/xtradb/os/os0file.cc | 37 +++++++++++++++++-------------
storage/xtradb/row/row0import.cc | 6 ++---
storage/xtradb/row/row0merge.cc | 6 ++---
15 files changed, 97 insertions(+), 69 deletions(-)
diff --git a/extra/innochecksum.cc b/extra/innochecksum.cc
index 03cc6a20a8d2c..2536926513a44 100644
--- a/extra/innochecksum.cc
+++ b/extra/innochecksum.cc
@@ -394,7 +394,8 @@ parse_page(
size_range_id = SIZE_RANGES_FOR_PAGE + 1;
}
if (per_page_details) {
- printf("index %lu page %lu leaf %u n_recs %lu data_bytes %lu"
+ printf("index " IB_ID_FMT " page " ULINTPF
+ " leaf %d n_recs " ULINTPF " data_bytes " ULINTPF
"\n", id, page_no, is_leaf, n_recs, data_bytes);
}
/* update per-index statistics */
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 0730683a2d334..4f825682138ec 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -4887,7 +4887,8 @@ buf_all_freed_instance(
block->page.space,
block->page.offset);
ib_logf(IB_LOG_LEVEL_ERROR,
- "Page oldest_modification %lu fix_count %d io_fix %d.",
+ "Page oldest_modification " LSN_PF
+ " fix_count %d io_fix %d.",
block->page.oldest_modification,
block->page.buf_fix_count,
buf_page_get_io_fix(&block->page));
diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc
index 5d5490fc43fe6..128a0dba31267 100644
--- a/storage/innobase/fil/fil0crypt.cc
+++ b/storage/innobase/fil/fil0crypt.cc
@@ -473,7 +473,7 @@ fil_parse_write_crypt_data(
4 + // size of key_id
1; // fil_encryption_t
- if (end_ptr - ptr < entry_size){
+ if (ptr + entry_size < end_ptr) {
return NULL;
}
@@ -499,7 +499,7 @@ fil_parse_write_crypt_data(
fil_encryption_t encryption = (fil_encryption_t)mach_read_from_1(ptr);
ptr +=1;
- if (end_ptr - ptr < len) {
+ if (ptr + len < end_ptr) {
return NULL;
}
@@ -1480,7 +1480,8 @@ fil_crypt_space_needs_rotation(
bool need_scrubbing =
crypt_data->rotate_state.scrubbing.is_active
- && diff >= srv_background_scrub_data_interval;
+ && diff >= 0
+ && ulint(diff) >= srv_background_scrub_data_interval;
if (need_key_rotation == false && need_scrubbing == false) {
break;
@@ -2378,7 +2379,9 @@ DECLARE_THREAD(fil_crypt_thread)(
time_t waited = time(0) - wait_start;
- if (waited >= srv_background_scrub_data_check_interval) {
+ if (waited >= 0
+ && ulint(waited)
+ >= srv_background_scrub_data_check_interval) {
break;
}
}
diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc
index 8f25366a47bbc..532ad2a3f76c8 100644
--- a/storage/innobase/lock/lock0lock.cc
+++ b/storage/innobase/lock/lock0lock.cc
@@ -918,8 +918,10 @@ lock_reset_lock_and_trx_wait(
}
ib_logf(IB_LOG_LEVEL_INFO,
- "Trx id %lu is waiting a lock in statement %s"
- " for this trx id %lu and statement %s wait_lock %p",
+ "Trx id " TRX_ID_FMT
+ " is waiting a lock in statement %s"
+ " for this trx id " TRX_ID_FMT
+ " and statement %s wait_lock %p",
lock->trx->id,
stmt ? stmt : "NULL",
trx_id,
@@ -2622,7 +2624,8 @@ lock_rec_add_to_queue(
if (wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
if (wsrep_debug) {
fprintf(stderr,
- "BF skipping wait: %lu\n",
+ "BF skipping wait: "
+ TRX_ID_FMT "\n",
trx->id);
lock_rec_print(stderr, lock);
}
@@ -5270,7 +5273,9 @@ lock_table_other_has_incompatible(
#ifdef WITH_WSREP
if(wsrep_thd_is_wsrep(trx->mysql_thd)) {
if (wsrep_debug) {
- fprintf(stderr, "WSREP: trx %ld table lock abort\n",
+ fprintf(stderr, "WSREP: trx "
+ TRX_ID_FMT
+ " table lock abort\n",
trx->id);
}
trx_mutex_enter(lock->trx);
diff --git a/storage/innobase/log/log0crypt.cc b/storage/innobase/log/log0crypt.cc
index db2e84d7e4517..dc9f3d577e68d 100644
--- a/storage/innobase/log/log0crypt.cc
+++ b/storage/innobase/log/log0crypt.cc
@@ -144,10 +144,12 @@ log_crypt_print_checkpoint_keys(
ib_uint64_t checkpoint_no = log_block_get_checkpoint_no(log_block);
if (crypt_info.size()) {
- fprintf(stderr, "InnoDB: redo log checkpoint: %lu [ chk key ]: ", checkpoint_no);
+ fprintf(stderr,
+ "InnoDB: redo log checkpoint: %llu [ chk key ]: ",
+ checkpoint_no);
for (size_t i = 0; i < crypt_info.size(); i++) {
struct crypt_info_t* it = &crypt_info[i];
- fprintf(stderr, "[ %lu %u ] ",
+ fprintf(stderr, "[ %llu %u ] ",
it->checkpoint_no,
it->key_version);
}
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index d212c9bec8ce8..e92526ceab07e 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -346,16 +346,17 @@ static os_ib_mutex_t os_file_count_mutex;
#endif /* !UNIV_HOTBACKUP && (!HAVE_ATOMIC_BUILTINS || UNIV_WORD_SIZE < 8) */
/** Number of pending os_file_pread() operations */
-UNIV_INTERN ulint os_file_n_pending_preads = 0;
+UNIV_INTERN ulint os_file_n_pending_preads;
/** Number of pending os_file_pwrite() operations */
-UNIV_INTERN ulint os_file_n_pending_pwrites = 0;
+UNIV_INTERN ulint os_file_n_pending_pwrites;
/** Number of pending write operations */
-UNIV_INTERN ulint os_n_pending_writes = 0;
+UNIV_INTERN ulint os_n_pending_writes;
/** Number of pending read operations */
-UNIV_INTERN ulint os_n_pending_reads = 0;
+UNIV_INTERN ulint os_n_pending_reads;
+#if defined(WIN_ASYNC_IO) || defined(LINUX_NATIVE_AIO)
/** After first fallocate failure we will disable os_file_trim */
-static ibool os_fallocate_failed;
+static bool os_fallocate_failed;
/**********************************************************************//**
Directly manipulate the allocated disk space by deallocating for the file referred to
@@ -369,6 +370,7 @@ ibool
os_file_trim(
/*=========*/
os_aio_slot_t* slot); /*!< in: slot structure */
+#endif /* WIN_ASYNC_IO || LINUX_NATIVE_AIO */
/****************************************************************//**
Does error handling when a file operation fails.
@@ -5262,7 +5264,7 @@ os_aio_windows_handle(
if (slot->type == OS_FILE_WRITE &&
!slot->is_log &&
srv_use_trim &&
- os_fallocate_failed == FALSE) {
+ !os_fallocate_failed) {
// Deallocate unused blocks from file system
os_file_trim(slot);
}
@@ -5359,7 +5361,7 @@ os_aio_linux_collect(
if (slot->type == OS_FILE_WRITE &&
!slot->is_log &&
srv_use_trim &&
- os_fallocate_failed == FALSE) {
+ !os_fallocate_failed) {
// Deallocate unused blocks from file system
os_file_trim(slot);
}
@@ -6220,6 +6222,7 @@ typedef struct _FILE_LEVEL_TRIM {
#endif
#endif
+#if defined(WIN_ASYNC_IO) || defined(LINUX_NATIVE_AIO)
/**********************************************************************//**
Directly manipulate the allocated disk space by deallocating for the file referred to
by fd for the byte range starting at offset and continuing for len bytes.
@@ -6227,7 +6230,7 @@ Within the specified range, partial file system blocks are zeroed, and whole
file system blocks are removed from the file. After a successful call,
subsequent reads from this range will return zeroes.
@return true if success, false if error */
-UNIV_INTERN
+static
ibool
os_file_trim(
/*=========*/
@@ -6273,13 +6276,13 @@ os_file_trim(
if (ret) {
/* After first failure do not try to trim again */
- os_fallocate_failed = TRUE;
+ os_fallocate_failed = true;
srv_use_trim = FALSE;
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Warning: fallocate call failed with error code %d.\n"
- " InnoDB: start: %lu len: %lu payload: %lu\n"
- " InnoDB: Disabling fallocate for now.\n", errno, off, trim_len, len);
+ ib_logf(IB_LOG_LEVEL_WARN,
+ "fallocate() failed with error %d."
+ " start: %llu len: " ULINTPF " payload: " ULINTPF "."
+ " Disabling fallocate for now.",
+ errno, off, ulint(trim_len), ulint(len));
os_file_handle_error_no_exit(slot->name,
" fallocate(FALLOC_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE) ",
@@ -6300,7 +6303,7 @@ os_file_trim(
fprintf(stderr,
" InnoDB: Warning: fallocate not supported on this installation."
" InnoDB: Disabling fallocate for now.");
- os_fallocate_failed = TRUE;
+ os_fallocate_failed = true;
srv_use_trim = FALSE;
if (slot->write_size) {
*slot->write_size = 0;
@@ -6320,7 +6323,7 @@ os_file_trim(
if (!ret) {
/* After first failure do not try to trim again */
- os_fallocate_failed = TRUE;
+ os_fallocate_failed = true;
srv_use_trim=FALSE;
ut_print_timestamp(stderr);
fprintf(stderr,
@@ -6374,6 +6377,7 @@ os_file_trim(
return (TRUE);
}
+#endif /* WIN_ASYNC_IO || LINUX_NATIVE_AIO */
#endif /* !UNIV_HOTBACKUP */
/***********************************************************************//**
diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc
index e9cfa126df0f0..9d3c695db1296 100644
--- a/storage/innobase/row/row0import.cc
+++ b/storage/innobase/row/row0import.cc
@@ -1870,10 +1870,10 @@ PageConverter::update_index_page(
if (index == 0) {
ib_logf(IB_LOG_LEVEL_ERROR,
- "Page for tablespace %lu is "
- " index page with id %lu but that"
+ "Page for tablespace " ULINTPF " is "
+ " index page with id " IB_ID_FMT " but that"
" index is not found from configuration file."
- " Current index name %s and id %lu.",
+ " Current index name %s and id " IB_ID_FMT ".",
m_space,
id,
m_index->m_name,
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index 047f2685d7a07..15d2ade303dd1 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -111,9 +111,8 @@ row_merge_encrypt_buf(
"Unable to encrypt data-block "
" src: %p srclen: %lu buf: %p buflen: %d."
" return-code: %d. Can't continue!\n",
- input_buf, (size_t)srv_sort_buf_size,
+ input_buf, srv_sort_buf_size,
crypted_buf, dstlen, rc);
- ut_error;
}
}
@@ -153,9 +152,8 @@ row_merge_decrypt_buf(
"Unable to encrypt data-block "
" src: %p srclen: %lu buf: %p buflen: %d."
" return-code: %d. Can't continue!\n",
- input_buf, (size_t)srv_sort_buf_size,
+ input_buf, srv_sort_buf_size,
crypted_buf, dstlen, rc);
- ut_error;
}
return true;
diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc
index b1156b4c64641..9bf6c9a1f43ab 100644
--- a/storage/xtradb/buf/buf0buf.cc
+++ b/storage/xtradb/buf/buf0buf.cc
@@ -5024,7 +5024,8 @@ buf_all_freed_instance(
block->page.space,
block->page.offset);
ib_logf(IB_LOG_LEVEL_ERROR,
- "Page oldest_modification %lu fix_count %d io_fix %d.",
+ "Page oldest_modification " LSN_PF
+ " fix_count %d io_fix %d.",
block->page.oldest_modification,
block->page.buf_fix_count,
buf_page_get_io_fix(&block->page));
diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc
index 251ace81e1511..31eb913c65075 100644
--- a/storage/xtradb/fil/fil0crypt.cc
+++ b/storage/xtradb/fil/fil0crypt.cc
@@ -473,7 +473,7 @@ fil_parse_write_crypt_data(
4 + // size of key_id
1; // fil_encryption_t
- if (end_ptr - ptr < entry_size){
+ if (ptr + entry_size < end_ptr) {
return NULL;
}
@@ -499,7 +499,7 @@ fil_parse_write_crypt_data(
fil_encryption_t encryption = (fil_encryption_t)mach_read_from_1(ptr);
ptr +=1;
- if (end_ptr - ptr < len) {
+ if (ptr + len < end_ptr) {
return NULL;
}
@@ -1479,7 +1479,8 @@ fil_crypt_space_needs_rotation(
bool need_scrubbing =
crypt_data->rotate_state.scrubbing.is_active
- && diff >= srv_background_scrub_data_interval;
+ && diff >= 0
+ && ulint(diff) >= srv_background_scrub_data_interval;
if (need_key_rotation == false && need_scrubbing == false) {
break;
@@ -2377,7 +2378,9 @@ DECLARE_THREAD(fil_crypt_thread)(
time_t waited = time(0) - wait_start;
- if (waited >= srv_background_scrub_data_check_interval) {
+ if (waited >= 0
+ && ulint(waited)
+ >= srv_background_scrub_data_check_interval) {
break;
}
}
diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc
index af2c823af64aa..163c5d9dc88ca 100644
--- a/storage/xtradb/lock/lock0lock.cc
+++ b/storage/xtradb/lock/lock0lock.cc
@@ -930,8 +930,10 @@ lock_reset_lock_and_trx_wait(
}
ib_logf(IB_LOG_LEVEL_INFO,
- "Trx id %lu is waiting a lock in statement %s"
- " for this trx id %lu and statement %s wait_lock %p",
+ "Trx id " TRX_ID_FMT
+ " is waiting a lock in statement %s"
+ " for this trx id " TRX_ID_FMT
+ " and statement %s wait_lock %p",
lock->trx->id,
stmt ? stmt : "NULL",
trx_id,
@@ -2654,7 +2656,8 @@ lock_rec_add_to_queue(
if (wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
if (wsrep_debug) {
fprintf(stderr,
- "BF skipping wait: %lu\n",
+ "BF skipping wait: "
+ TRX_ID_FMT "\n",
trx->id);
lock_rec_print(stderr, lock);
}
@@ -5316,7 +5319,9 @@ lock_table_other_has_incompatible(
#ifdef WITH_WSREP
if(wsrep_thd_is_wsrep(trx->mysql_thd)) {
if (wsrep_debug) {
- fprintf(stderr, "WSREP: trx %ld table lock abort\n",
+ fprintf(stderr, "WSREP: trx "
+ TRX_ID_FMT
+ " table lock abort\n",
trx->id);
}
trx_mutex_enter(lock->trx);
diff --git a/storage/xtradb/log/log0crypt.cc b/storage/xtradb/log/log0crypt.cc
index db2e84d7e4517..dc9f3d577e68d 100644
--- a/storage/xtradb/log/log0crypt.cc
+++ b/storage/xtradb/log/log0crypt.cc
@@ -144,10 +144,12 @@ log_crypt_print_checkpoint_keys(
ib_uint64_t checkpoint_no = log_block_get_checkpoint_no(log_block);
if (crypt_info.size()) {
- fprintf(stderr, "InnoDB: redo log checkpoint: %lu [ chk key ]: ", checkpoint_no);
+ fprintf(stderr,
+ "InnoDB: redo log checkpoint: %llu [ chk key ]: ",
+ checkpoint_no);
for (size_t i = 0; i < crypt_info.size(); i++) {
struct crypt_info_t* it = &crypt_info[i];
- fprintf(stderr, "[ %lu %u ] ",
+ fprintf(stderr, "[ %llu %u ] ",
it->checkpoint_no,
it->key_version);
}
diff --git a/storage/xtradb/os/os0file.cc b/storage/xtradb/os/os0file.cc
index cdc3df5e851ed..7b3b880040767 100644
--- a/storage/xtradb/os/os0file.cc
+++ b/storage/xtradb/os/os0file.cc
@@ -346,16 +346,17 @@ static os_ib_mutex_t os_file_count_mutex;
#endif /* !UNIV_HOTBACKUP && (!HAVE_ATOMIC_BUILTINS || UNIV_WORD_SIZE < 8) */
/** Number of pending os_file_pread() operations */
-UNIV_INTERN ulint os_file_n_pending_preads = 0;
+UNIV_INTERN ulint os_file_n_pending_preads;
/** Number of pending os_file_pwrite() operations */
-UNIV_INTERN ulint os_file_n_pending_pwrites = 0;
+UNIV_INTERN ulint os_file_n_pending_pwrites;
/** Number of pending write operations */
-UNIV_INTERN ulint os_n_pending_writes = 0;
+UNIV_INTERN ulint os_n_pending_writes;
/** Number of pending read operations */
-UNIV_INTERN ulint os_n_pending_reads = 0;
+UNIV_INTERN ulint os_n_pending_reads;
+#if defined(WIN_ASYNC_IO) || defined(LINUX_NATIVE_AIO)
/** After first fallocate failure we will disable os_file_trim */
-static ibool os_fallocate_failed;
+static bool os_fallocate_failed;
/**********************************************************************//**
Directly manipulate the allocated disk space by deallocating for the file referred to
@@ -369,6 +370,7 @@ ibool
os_file_trim(
/*=========*/
os_aio_slot_t* slot); /*!< in: slot structure */
+#endif /* WIN_ASYNC_IO || LINUX_NATIVE_AIO */
/****************************************************************//**
Does error handling when a file operation fails.
@@ -5336,7 +5338,7 @@ os_aio_windows_handle(
}
if (slot->type == OS_FILE_WRITE) {
- if (!slot->is_log && srv_use_trim && os_fallocate_failed == FALSE) {
+ if (!slot->is_log && srv_use_trim && !os_fallocate_failed) {
// Deallocate unused blocks from file system
os_file_trim(slot);
}
@@ -5432,7 +5434,8 @@ os_aio_linux_collect(
ut_a(slot->pos < end_pos);
if (slot->type == OS_FILE_WRITE) {
- if (!slot->is_log && srv_use_trim && os_fallocate_failed == FALSE) {
+ if (!slot->is_log && srv_use_trim
+ && !os_fallocate_failed) {
// Deallocate unused blocks from file system
os_file_trim(slot);
}
@@ -6334,6 +6337,7 @@ typedef struct _FILE_LEVEL_TRIM {
#endif
#endif
+#if defined(WIN_ASYNC_IO) || defined(LINUX_NATIVE_AIO)
/**********************************************************************//**
Directly manipulate the allocated disk space by deallocating for the file referred to
by fd for the byte range starting at offset and continuing for len bytes.
@@ -6341,7 +6345,7 @@ Within the specified range, partial file system blocks are zeroed, and whole
file system blocks are removed from the file. After a successful call,
subsequent reads from this range will return zeroes.
@return true if success, false if error */
-UNIV_INTERN
+static
ibool
os_file_trim(
/*=========*/
@@ -6386,13 +6390,13 @@ os_file_trim(
if (ret) {
/* After first failure do not try to trim again */
- os_fallocate_failed = TRUE;
+ os_fallocate_failed = true;
srv_use_trim = FALSE;
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Warning: fallocate call failed with error code %d.\n"
- " InnoDB: start: %lu len: %lu payload: %lu\n"
- " InnoDB: Disabling fallocate for now.\n", errno, off, trim_len, len);
+ ib_logf(IB_LOG_LEVEL_WARN,
+ "fallocate() failed with error %d."
+ " start: %llu len: " ULINTPF " payload: " ULINTPF "."
+ " Disabling fallocate for now.",
+ errno, off, ulint(trim_len), ulint(len));
os_file_handle_error_no_exit(slot->name,
" fallocate(FALLOC_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE) ",
@@ -6413,7 +6417,7 @@ os_file_trim(
fprintf(stderr,
" InnoDB: Warning: fallocate not supported on this installation."
" InnoDB: Disabling fallocate for now.");
- os_fallocate_failed = TRUE;
+ os_fallocate_failed = true;
srv_use_trim = FALSE;
if (slot->write_size) {
*slot->write_size = 0;
@@ -6433,7 +6437,7 @@ os_file_trim(
if (!ret) {
/* After first failure do not try to trim again */
- os_fallocate_failed = TRUE;
+ os_fallocate_failed = true;
srv_use_trim = FALSE;
ut_print_timestamp(stderr);
fprintf(stderr,
@@ -6487,6 +6491,7 @@ os_file_trim(
return (TRUE);
}
+#endif /* WIN_ASYNC_IO || LINUX_NATIVE_AIO */
/***********************************************************************//**
Try to get number of bytes per sector from file system.
diff --git a/storage/xtradb/row/row0import.cc b/storage/xtradb/row/row0import.cc
index 4e8488f88a8c5..6dc01907710f9 100644
--- a/storage/xtradb/row/row0import.cc
+++ b/storage/xtradb/row/row0import.cc
@@ -1874,10 +1874,10 @@ PageConverter::update_index_page(
if (index == 0) {
ib_logf(IB_LOG_LEVEL_ERROR,
- "Page for tablespace %lu is "
- " index page with id %lu but that"
+ "Page for tablespace " ULINTPF " is "
+ " index page with id " IB_ID_FMT " but that"
" index is not found from configuration file."
- " Current index name %s and id %lu.",
+ " Current index name %s and id " IB_ID_FMT ".",
m_space,
id,
m_index->m_name,
diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc
index 7bf5c98ee5ff8..81142bfcb5292 100644
--- a/storage/xtradb/row/row0merge.cc
+++ b/storage/xtradb/row/row0merge.cc
@@ -112,9 +112,8 @@ row_merge_encrypt_buf(
"Unable to encrypt data-block "
" src: %p srclen: %lu buf: %p buflen: %d."
" return-code: %d. Can't continue!\n",
- input_buf, (size_t)srv_sort_buf_size,
+ input_buf, srv_sort_buf_size,
crypted_buf, dstlen, rc);
- ut_error;
}
}
@@ -154,9 +153,8 @@ row_merge_decrypt_buf(
"Unable to encrypt data-block "
" src: %p srclen: %lu buf: %p buflen: %d."
" return-code: %d. Can't continue!\n",
- input_buf, (size_t)srv_sort_buf_size,
+ input_buf, srv_sort_buf_size,
crypted_buf, dstlen, rc);
- ut_error;
}
return (true);
From 2158de88659892bcd723fb5c3c722d8b2ed63ce2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?=
Date: Thu, 9 Mar 2017 11:26:36 +0200
Subject: [PATCH 155/226] Remove unused variables.
---
sql/handler.cc | 1 -
storage/myisam/mi_delete_table.c | 1 -
2 files changed, 2 deletions(-)
diff --git a/sql/handler.cc b/sql/handler.cc
index d75d3e3ef2154..8b0f885bb6363 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -3841,7 +3841,6 @@ int handler::delete_table(const char *name)
int saved_error= 0;
int error= 0;
int enoent_or_zero;
- char buff[FN_REFLEN];
if (ht->discover_table)
enoent_or_zero= 0; // the table may not exist in the engine, it's ok
diff --git a/storage/myisam/mi_delete_table.c b/storage/myisam/mi_delete_table.c
index a72a94b06d26c..3422e6b045dc7 100644
--- a/storage/myisam/mi_delete_table.c
+++ b/storage/myisam/mi_delete_table.c
@@ -28,7 +28,6 @@
int mi_delete_table(const char *name)
{
- int res;
DBUG_ENTER("mi_delete_table");
#ifdef EXTRA_DEBUG
From 8805fe0d5c51925c3649cb7ea2df84944370852e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?=
Date: Thu, 9 Mar 2017 11:27:24 +0200
Subject: [PATCH 156/226] Use %pure-parser instead of the deprecated
%pure_parser.
---
sql/sql_yacc.yy | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 9885cd729b40b..cd5b96577303e 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -959,7 +959,7 @@ static bool sp_create_assignment_instr(THD *thd, bool no_lookahead)
bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%}
-%pure_parser /* We have threads */
+%pure-parser /* We have threads */
%parse-param { THD *thd }
%lex-param { THD *thd }
/*
From 1b2b209519c1ffd03ec2a1639d64d994e5d9090d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?=
Date: Thu, 9 Mar 2017 11:28:07 +0200
Subject: [PATCH 157/226] Use correct integer format with printf-like
functions.
---
storage/innobase/buf/buf0buf.cc | 3 ++-
storage/maria/ma_pagecache.c | 14 +++++++-------
storage/xtradb/buf/buf0buf.cc | 3 ++-
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 2c7c578150d34..73d061c4b20ef 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -4415,7 +4415,8 @@ buf_all_freed_instance(
block->page.space,
block->page.offset);
ib_logf(IB_LOG_LEVEL_ERROR,
- "Page oldest_modification %lu fix_count %d io_fix %d.",
+ "Page oldest_modification " LSN_PF
+ " fix_count %d io_fix %d.",
block->page.oldest_modification,
block->page.buf_fix_count,
buf_page_get_io_fix(&block->page));
diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c
index d3eb687d064c0..50439785eca77 100644
--- a/storage/maria/ma_pagecache.c
+++ b/storage/maria/ma_pagecache.c
@@ -883,8 +883,8 @@ size_t init_pagecache(PAGECACHE *pagecache, size_t use_mem,
pagecache->waiting_for_hash_link.last_thread= NULL;
pagecache->waiting_for_block.last_thread= NULL;
DBUG_PRINT("exit",
- ("disk_blocks: %ld block_root: 0x%lx hash_entries: %ld\
- hash_root: 0x%lx hash_links: %ld hash_link_root: 0x%lx",
+ ("disk_blocks: %zu block_root: 0x%lx hash_entries: %zu\
+ hash_root: 0x%lx hash_links: %zu hash_link_root: 0x%lx",
pagecache->disk_blocks, (long) pagecache->block_root,
pagecache->hash_entries, (long) pagecache->hash_root,
pagecache->hash_links, (long) pagecache->hash_link_root));
@@ -1182,7 +1182,7 @@ void end_pagecache(PAGECACHE *pagecache, my_bool cleanup)
pagecache->blocks_changed= 0;
}
- DBUG_PRINT("status", ("used: %lu changed: %lu w_requests: %lu "
+ DBUG_PRINT("status", ("used: %zu changed: %zu w_requests: %lu "
"writes: %lu r_requests: %lu reads: %lu",
pagecache->blocks_used,
pagecache->global_blocks_changed,
@@ -1517,7 +1517,7 @@ static void unreg_request(PAGECACHE *pagecache,
if (block->temperature == PCBLOCK_WARM)
pagecache->warm_blocks--;
block->temperature= PCBLOCK_HOT;
- KEYCACHE_DBUG_PRINT("unreg_request", ("#warm_blocks: %lu",
+ KEYCACHE_DBUG_PRINT("unreg_request", ("#warm_blocks: %zu",
pagecache->warm_blocks));
}
link_block(pagecache, block, hot, (my_bool)at_end);
@@ -1536,7 +1536,7 @@ static void unreg_request(PAGECACHE *pagecache,
pagecache->warm_blocks++;
block->temperature= PCBLOCK_WARM;
}
- KEYCACHE_DBUG_PRINT("unreg_request", ("#warm_blocks: %lu",
+ KEYCACHE_DBUG_PRINT("unreg_request", ("#warm_blocks: %zu",
pagecache->warm_blocks));
}
}
@@ -4491,7 +4491,7 @@ static int flush_pagecache_blocks_int(PAGECACHE *pagecache,
int rc= PCFLUSH_OK;
DBUG_ENTER("flush_pagecache_blocks_int");
DBUG_PRINT("enter",
- ("fd: %d blocks_used: %lu blocks_changed: %lu type: %d",
+ ("fd: %d blocks_used: %zu blocks_changed: %zu type: %d",
file->file, pagecache->blocks_used, pagecache->blocks_changed,
type));
@@ -4956,7 +4956,7 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache,
ptr= str->str;
int8store(ptr, (ulonglong)stored_list_size);
ptr+= 8;
- DBUG_PRINT("info", ("found %lu dirty pages", stored_list_size));
+ DBUG_PRINT("info", ("found %zu dirty pages", stored_list_size));
if (stored_list_size == 0)
goto end;
for (file_hash= 0; file_hash < pagecache->changed_blocks_hash_size; file_hash++)
diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc
index 520997591e811..a5d8b661c35f6 100644
--- a/storage/xtradb/buf/buf0buf.cc
+++ b/storage/xtradb/buf/buf0buf.cc
@@ -4694,7 +4694,8 @@ buf_all_freed_instance(
block->page.space,
block->page.offset);
ib_logf(IB_LOG_LEVEL_ERROR,
- "Page oldest_modification %lu fix_count %d io_fix %d.",
+ "Page oldest_modification " LSN_PF
+ " fix_count %d io_fix %d.",
block->page.oldest_modification,
block->page.buf_fix_count,
buf_page_get_io_fix(&block->page));
From 2abc313c3794f2a38e2485ded041a6cca0ad1172 Mon Sep 17 00:00:00 2001
From: Sergei Petrunia
Date: Thu, 9 Mar 2017 12:34:06 +0300
Subject: [PATCH 158/226] Use correct function name in DEBUG_ENTER
---
sql/sql_prepare.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 6727b2a018290..094677e150da5 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1988,7 +1988,7 @@ static int mysql_test_handler_read(Prepared_statement *stmt,
THD *thd= stmt->thd;
LEX *lex= stmt->lex;
SQL_HANDLER *ha_table;
- DBUG_ENTER("mysql_test_select");
+ DBUG_ENTER("mysql_test_handler_read");
lex->select_lex.context.resolve_in_select_list= TRUE;
From b28adb6a62661b60f80c7c1b6237b74fb7cdcee2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?=
Date: Thu, 9 Mar 2017 15:09:44 +0200
Subject: [PATCH 159/226] Fix an error introduced in the previous commit.
fil_parse_write_crypt_data(): Correct the comparison operator.
This was broken in commit 498f4a825b29a37cb27f1c76741987de8c510d06
which removed a signed/unsigned mismatch in these comparisons.
---
storage/innobase/fil/fil0crypt.cc | 4 ++--
storage/xtradb/fil/fil0crypt.cc | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc
index 128a0dba31267..f19b29d347b49 100644
--- a/storage/innobase/fil/fil0crypt.cc
+++ b/storage/innobase/fil/fil0crypt.cc
@@ -473,7 +473,7 @@ fil_parse_write_crypt_data(
4 + // size of key_id
1; // fil_encryption_t
- if (ptr + entry_size < end_ptr) {
+ if (ptr + entry_size > end_ptr) {
return NULL;
}
@@ -499,7 +499,7 @@ fil_parse_write_crypt_data(
fil_encryption_t encryption = (fil_encryption_t)mach_read_from_1(ptr);
ptr +=1;
- if (ptr + len < end_ptr) {
+ if (ptr + len > end_ptr) {
return NULL;
}
diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc
index 31eb913c65075..eaa7da4f1449d 100644
--- a/storage/xtradb/fil/fil0crypt.cc
+++ b/storage/xtradb/fil/fil0crypt.cc
@@ -473,7 +473,7 @@ fil_parse_write_crypt_data(
4 + // size of key_id
1; // fil_encryption_t
- if (ptr + entry_size < end_ptr) {
+ if (ptr + entry_size > end_ptr) {
return NULL;
}
@@ -499,7 +499,7 @@ fil_parse_write_crypt_data(
fil_encryption_t encryption = (fil_encryption_t)mach_read_from_1(ptr);
ptr +=1;
- if (ptr + len < end_ptr) {
+ if (ptr + len > end_ptr) {
return NULL;
}
From 5aacb861f2e84e1f45d72bf34fdaffa0904a9f5b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?=
Date: Thu, 9 Mar 2017 14:45:52 +0200
Subject: [PATCH 160/226] WSREP: Use TRX_ID_FMT for trx_id_t in messages.
---
storage/innobase/handler/ha_innodb.cc | 30 ++++++++++++++++-----------
storage/xtradb/handler/ha_innodb.cc | 30 ++++++++++++++++-----------
2 files changed, 36 insertions(+), 24 deletions(-)
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 8c01c3f8aa542..54ae4c5dcf5c4 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -18483,19 +18483,21 @@ wsrep_innobase_kill_one_trx(
if (!thd) {
DBUG_PRINT("wsrep", ("no thd for conflicting lock"));
- WSREP_WARN("no THD for trx: %lu", victim_trx->id);
+ WSREP_WARN("no THD for trx: " TRX_ID_FMT, victim_trx->id);
DBUG_RETURN(1);
}
if (!bf_thd) {
DBUG_PRINT("wsrep", ("no BF thd for conflicting lock"));
- WSREP_WARN("no BF THD for trx: %lu", (bf_trx) ? bf_trx->id : 0);
+ WSREP_WARN("no BF THD for trx: " TRX_ID_FMT,
+ bf_trx ? bf_trx->id : 0);
DBUG_RETURN(1);
}
WSREP_LOG_CONFLICT(bf_thd, thd, TRUE);
- WSREP_DEBUG("BF kill (%lu, seqno: %lld), victim: (%lu) trx: %lu",
+ WSREP_DEBUG("BF kill (%lu, seqno: %lld), victim: (%lu) trx: "
+ TRX_ID_FMT,
signal, (long long)bf_seqno,
thd_get_thread_id(thd),
victim_trx->id);
@@ -18515,13 +18517,14 @@ wsrep_innobase_kill_one_trx(
if (wsrep_thd_query_state(thd) == QUERY_EXITING) {
- WSREP_DEBUG("kill trx EXITING for %lu", victim_trx->id);
+ WSREP_DEBUG("kill trx EXITING for " TRX_ID_FMT,
+ victim_trx->id);
wsrep_thd_UNLOCK(thd);
DBUG_RETURN(0);
}
if(wsrep_thd_exec_mode(thd) != LOCAL_STATE) {
- WSREP_DEBUG("withdraw for BF trx: %lu, state: %d",
+ WSREP_DEBUG("withdraw for BF trx: " TRX_ID_FMT ", state: %d",
victim_trx->id,
wsrep_thd_get_conflict_state(thd));
}
@@ -18531,7 +18534,7 @@ wsrep_innobase_kill_one_trx(
wsrep_thd_set_conflict_state(thd, MUST_ABORT);
break;
case MUST_ABORT:
- WSREP_DEBUG("victim %lu in MUST ABORT state",
+ WSREP_DEBUG("victim " TRX_ID_FMT " in MUST ABORT state",
victim_trx->id);
wsrep_thd_UNLOCK(thd);
wsrep_thd_awake(thd, signal);
@@ -18540,7 +18543,7 @@ wsrep_innobase_kill_one_trx(
case ABORTED:
case ABORTING: // fall through
default:
- WSREP_DEBUG("victim %lu in state %d",
+ WSREP_DEBUG("victim " TRX_ID_FMT " in state %d",
victim_trx->id, wsrep_thd_get_conflict_state(thd));
wsrep_thd_UNLOCK(thd);
DBUG_RETURN(0);
@@ -18553,7 +18556,7 @@ wsrep_innobase_kill_one_trx(
WSREP_DEBUG("kill query for: %ld",
thd_get_thread_id(thd));
- WSREP_DEBUG("kill trx QUERY_COMMITTING for %lu",
+ WSREP_DEBUG("kill trx QUERY_COMMITTING for " TRX_ID_FMT,
victim_trx->id);
if (wsrep_thd_exec_mode(thd) == REPL_RECV) {
@@ -18568,7 +18571,8 @@ wsrep_innobase_kill_one_trx(
switch (rcode) {
case WSREP_WARNING:
- WSREP_DEBUG("cancel commit warning: %lu",
+ WSREP_DEBUG("cancel commit warning: "
+ TRX_ID_FMT,
victim_trx->id);
wsrep_thd_UNLOCK(thd);
wsrep_thd_awake(thd, signal);
@@ -18578,7 +18582,8 @@ wsrep_innobase_kill_one_trx(
break;
default:
WSREP_ERROR(
- "cancel commit bad exit: %d %lu",
+ "cancel commit bad exit: %d "
+ TRX_ID_FMT,
rcode,
victim_trx->id);
/* unable to interrupt, must abort */
@@ -18596,7 +18601,8 @@ wsrep_innobase_kill_one_trx(
/* it is possible that victim trx is itself waiting for some
* other lock. We need to cancel this waiting
*/
- WSREP_DEBUG("kill trx QUERY_EXEC for %lu", victim_trx->id);
+ WSREP_DEBUG("kill trx QUERY_EXEC for " TRX_ID_FMT,
+ victim_trx->id);
victim_trx->lock.was_chosen_as_deadlock_victim= TRUE;
if (victim_trx->lock.wait_lock) {
@@ -18631,7 +18637,7 @@ wsrep_innobase_kill_one_trx(
break;
case QUERY_IDLE:
{
- WSREP_DEBUG("kill IDLE for %lu", victim_trx->id);
+ WSREP_DEBUG("kill IDLE for " TRX_ID_FMT, victim_trx->id);
if (wsrep_thd_exec_mode(thd) == REPL_RECV) {
WSREP_DEBUG("kill BF IDLE, seqno: %lld",
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index 5a10492fa62b6..b61fd6c1b5e4e 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -19628,19 +19628,21 @@ wsrep_innobase_kill_one_trx(
if (!thd) {
DBUG_PRINT("wsrep", ("no thd for conflicting lock"));
- WSREP_WARN("no THD for trx: %lu", victim_trx->id);
+ WSREP_WARN("no THD for trx: " TRX_ID_FMT, victim_trx->id);
DBUG_RETURN(1);
}
if (!bf_thd) {
DBUG_PRINT("wsrep", ("no BF thd for conflicting lock"));
- WSREP_WARN("no BF THD for trx: %lu", (bf_trx) ? bf_trx->id : 0);
+ WSREP_WARN("no BF THD for trx: " TRX_ID_FMT,
+ bf_trx ? bf_trx->id : 0);
DBUG_RETURN(1);
}
WSREP_LOG_CONFLICT(bf_thd, thd, TRUE);
- WSREP_DEBUG("BF kill (%lu, seqno: %lld), victim: (%lu) trx: %lu",
+ WSREP_DEBUG("BF kill (%lu, seqno: %lld), victim: (%lu) trx: "
+ TRX_ID_FMT,
signal, (long long)bf_seqno,
thd_get_thread_id(thd),
victim_trx->id);
@@ -19660,13 +19662,14 @@ wsrep_innobase_kill_one_trx(
if (wsrep_thd_query_state(thd) == QUERY_EXITING) {
- WSREP_DEBUG("kill trx EXITING for %lu", victim_trx->id);
+ WSREP_DEBUG("kill trx EXITING for " TRX_ID_FMT,
+ victim_trx->id);
wsrep_thd_UNLOCK(thd);
DBUG_RETURN(0);
}
if(wsrep_thd_exec_mode(thd) != LOCAL_STATE) {
- WSREP_DEBUG("withdraw for BF trx: %lu, state: %d",
+ WSREP_DEBUG("withdraw for BF trx: " TRX_ID_FMT ", state: %d",
victim_trx->id,
wsrep_thd_get_conflict_state(thd));
}
@@ -19676,7 +19679,7 @@ wsrep_innobase_kill_one_trx(
wsrep_thd_set_conflict_state(thd, MUST_ABORT);
break;
case MUST_ABORT:
- WSREP_DEBUG("victim %lu in MUST ABORT state",
+ WSREP_DEBUG("victim " TRX_ID_FMT " in MUST ABORT state",
victim_trx->id);
wsrep_thd_UNLOCK(thd);
wsrep_thd_awake(thd, signal);
@@ -19685,7 +19688,7 @@ wsrep_innobase_kill_one_trx(
case ABORTED:
case ABORTING: // fall through
default:
- WSREP_DEBUG("victim %lu in state %d",
+ WSREP_DEBUG("victim " TRX_ID_FMT " in state %d",
victim_trx->id, wsrep_thd_get_conflict_state(thd));
wsrep_thd_UNLOCK(thd);
DBUG_RETURN(0);
@@ -19698,7 +19701,7 @@ wsrep_innobase_kill_one_trx(
WSREP_DEBUG("kill query for: %ld",
thd_get_thread_id(thd));
- WSREP_DEBUG("kill trx QUERY_COMMITTING for %lu",
+ WSREP_DEBUG("kill trx QUERY_COMMITTING for " TRX_ID_FMT,
victim_trx->id);
if (wsrep_thd_exec_mode(thd) == REPL_RECV) {
@@ -19713,7 +19716,8 @@ wsrep_innobase_kill_one_trx(
switch (rcode) {
case WSREP_WARNING:
- WSREP_DEBUG("cancel commit warning: %lu",
+ WSREP_DEBUG("cancel commit warning: "
+ TRX_ID_FMT,
victim_trx->id);
wsrep_thd_UNLOCK(thd);
wsrep_thd_awake(thd, signal);
@@ -19723,7 +19727,8 @@ wsrep_innobase_kill_one_trx(
break;
default:
WSREP_ERROR(
- "cancel commit bad exit: %d %lu",
+ "cancel commit bad exit: %d "
+ TRX_ID_FMT,
rcode,
victim_trx->id);
/* unable to interrupt, must abort */
@@ -19741,7 +19746,8 @@ wsrep_innobase_kill_one_trx(
/* it is possible that victim trx is itself waiting for some
* other lock. We need to cancel this waiting
*/
- WSREP_DEBUG("kill trx QUERY_EXEC for %lu", victim_trx->id);
+ WSREP_DEBUG("kill trx QUERY_EXEC for " TRX_ID_FMT,
+ victim_trx->id);
victim_trx->lock.was_chosen_as_deadlock_victim= TRUE;
if (victim_trx->lock.wait_lock) {
@@ -19776,7 +19782,7 @@ wsrep_innobase_kill_one_trx(
break;
case QUERY_IDLE:
{
- WSREP_DEBUG("kill IDLE for %lu", victim_trx->id);
+ WSREP_DEBUG("kill IDLE for " TRX_ID_FMT, victim_trx->id);
if (wsrep_thd_exec_mode(thd) == REPL_RECV) {
WSREP_DEBUG("kill BF IDLE, seqno: %lld",
From 1d47bd61d55e636da1f10a7b22755b2e929c83f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?=
Date: Thu, 9 Mar 2017 16:52:57 +0200
Subject: [PATCH 161/226] Remove leftover merge conflict marker
---
mysql-test/valgrind.supp | 1 -
1 file changed, 1 deletion(-)
diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp
index e6aa030859f87..bde01a648f919 100644
--- a/mysql-test/valgrind.supp
+++ b/mysql-test/valgrind.supp
@@ -1144,7 +1144,6 @@
...
fun:pthread_create*
}
-<<<<<<< HEAD
{
Memory Leak in loader and valgrind malloc
From 07d89fa59c1734b5a963943dcb93ade0c4e92e48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?=
Date: Thu, 9 Mar 2017 16:52:57 +0200
Subject: [PATCH 162/226] Remove leftover merge conflict marker
---
mysql-test/valgrind.supp | 1 -
1 file changed, 1 deletion(-)
diff --git a/mysql-test/valgrind.supp b/mysql-test/valgrind.supp
index 08086033fc982..0eab439840d98 100644
--- a/mysql-test/valgrind.supp
+++ b/mysql-test/valgrind.supp
@@ -1129,7 +1129,6 @@
...
fun:pthread_create*
}
-<<<<<<< HEAD
{
Memory Leak in loader and valgrind malloc
From 18de8296182f42cdf663573949a82950b72af8fc Mon Sep 17 00:00:00 2001
From: iangilfillan
Date: Thu, 9 Mar 2017 13:18:40 +0200
Subject: [PATCH 163/226] MDEV-11964 Add missing stub manpages
---
man/mariadb-service-convert.1 | 20 +++
man/mysqld_safe_helper.1 | 16 +++
man/tokuftdump.1 | 237 ++++++++++++++++++++++++++++++++++
man/wsrep_sst_common.1 | 16 +++
man/wsrep_sst_mysqldump.1 | 16 +++
man/wsrep_sst_rsync.1 | 16 +++
man/wsrep_sst_xtrabackup-v2.1 | 16 +++
man/wsrep_sst_xtrabackup.1 | 16 +++
8 files changed, 353 insertions(+)
create mode 100644 man/mariadb-service-convert.1
create mode 100644 man/mysqld_safe_helper.1
create mode 100644 man/tokuftdump.1
create mode 100644 man/wsrep_sst_common.1
create mode 100644 man/wsrep_sst_mysqldump.1
create mode 100644 man/wsrep_sst_rsync.1
create mode 100644 man/wsrep_sst_xtrabackup-v2.1
create mode 100644 man/wsrep_sst_xtrabackup.1
diff --git a/man/mariadb-service-convert.1 b/man/mariadb-service-convert.1
new file mode 100644
index 0000000000000..6301087208b13
--- /dev/null
+++ b/man/mariadb-service-convert.1
@@ -0,0 +1,20 @@
+'\" t
+.\"
+.TH "\FBMARIADB-SERVICE-CONVERT\FR" "1" "26 January 2017" "MariaDB 10\&.1" "MariaDB Database System"
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.SH NAME
+mariadb-service-convert \- generate a mariadb.service file based on the current mysql/mariadb settings
+.SH DESCRIPTION
+Use: Generate a mariadb.service file based on the current mysql/mariadb settings\.
+This is to assist distro maintainers in migrating to systemd service definations from
+a user mysqld_safe settings in the my.cnf files\.
+.PP
+Redirect output to user directory like /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
+.PP
+For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/
diff --git a/man/mysqld_safe_helper.1 b/man/mysqld_safe_helper.1
new file mode 100644
index 0000000000000..63770a49d28b9
--- /dev/null
+++ b/man/mysqld_safe_helper.1
@@ -0,0 +1,16 @@
+'\" t
+.\"
+.TH "\FBMYSQLD_SAFE_HELPER\FR" "1" "26 January 2017" "MariaDB 10\&.1" "MariaDB Database System"
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.SH NAME
+mysqld_safe_helper \- helper script
+.SH DESCRIPTION
+Use: Helper script\.
+.PP
+For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/
diff --git a/man/tokuftdump.1 b/man/tokuftdump.1
new file mode 100644
index 0000000000000..d0a11a840a551
--- /dev/null
+++ b/man/tokuftdump.1
@@ -0,0 +1,237 @@
+'\" t
+.\"
+.TH "\FBTOKUFTDUMP\FR" "1" "9 March 2017" "MariaDB 10\&.1" "MariaDB Database System"
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.\" tokuftdump
+.\" upgrading MySQL
+.SH "NAME"
+tokuftdump \- look into the fractal tree file
+.SH "SYNOPSIS"
+.HP \w'\fBtokuftdump\ [\fR\fB\fIoptions\fR\fR\fB]\fR\ 'u
+\fBtokuftdump [\fR\fB\fIoptions\fR\fR\fB]\fR
+.SH "DESCRIPTION"
+.PP
+\fBtokuftdump\fR
+Investigates and diagnoses the fractal tree\&.
+.PP
+\fBtokuftdump\fR
+supports the following options for processing option files\&.
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+.\" tokuftdump: interactive option
+.\" interactive option: tokuftdump
+\fB\-\-interactive\fR
+.sp
+Interactive\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+.\" tokuftdump: support option
+.\" support option: tokuftdump
+\fB\-\-support \fI/path/to/fractal-tree/file\fR
+.sp
+An interactive way to see what messages and/or switch between FTs\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+.\" tokuftdump: json option
+.\" json option: tokuftdump
+\fB\-\-json \fI/path/to/fractal-tree/file [output_json_file]\fR
+.sp
+If the output json file is left empty, FT\&.json will be created automatically\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+.\" tokuftdump: nodata option
+.\" nodata option: tokuftdump
+\fB\-\-nodata\fR
+.sp
+Nodata\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+.\" tokuftdump: dumpdata option
+.\" dumpdata option: tokuftdump
+\fB\-\-dumpdata = \fR\fB\fI0|1\fR\fR
+.sp
+Dumpdata\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+.\" tokuftdump: header option
+.\" header option: tokuftdump
+\fB\-\-header\fR
+.sp
+Header\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+.\" tokuftdump: rootnode option
+.\" rootnode option: tokuftdump
+\fB\-\-rootnode\fR
+.sp
+Rootnode\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+.\" tokuftdump: node option
+.\" node option: tokuftdump
+\fB\-\-node \fIN\fR
+.sp
+Node\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+.\" tokuftdump: fragmentation option
+.\" fragmentation option: tokuftdump
+\fB\-\-fragmentation\fR
+.sp
+Fragmentation\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+.\" tokuftdump: garbage option
+.\" garbage option: tokuftdump
+\fB\-\-garbage\fR
+.sp
+Garbage\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+.\" tokuftdump: tsv option
+.\" tsv option: tokuftdump
+\fB\-\-tsv\fR
+.sp
+TSV\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+.\" tokuftdump: translation-table option
+.\" translation-table option: tokuftdump
+\fB\-\-translation\-table\fR
+.sp
+Translation table\&.
+.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+.\" tokuftdump: summary option
+.\" summary option: tokuftdump
+\fB\-\-summary\fR
+.sp
+Provide summary info\&.
+.RE
+.SH "COPYRIGHT"
+.br
+.PP
+Copyright 2016 MariaDB Foundation
+.PP
+This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
+.PP
+This documentation 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.
+.PP
+You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/.
+.sp
+.SH "SEE ALSO"
+For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/
+.SH AUTHOR
+MariaDB Foundation (http://www.mariadb.org/).
diff --git a/man/wsrep_sst_common.1 b/man/wsrep_sst_common.1
new file mode 100644
index 0000000000000..05242e66c0000
--- /dev/null
+++ b/man/wsrep_sst_common.1
@@ -0,0 +1,16 @@
+'\" t
+.\"
+.TH "\FBWSREP_SST_COMMON\FR" "1" "26 January 2017" "MariaDB 10\&.1" "MariaDB Database System"
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.SH NAME
+wsrep_sst_common \- common command line parser to be sourced by other SST scripts
+.SH DESCRIPTION
+Use: Common command line parser to be sourced by other SST scripts\.
+.PP
+For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/
diff --git a/man/wsrep_sst_mysqldump.1 b/man/wsrep_sst_mysqldump.1
new file mode 100644
index 0000000000000..17ad5b2cdf18b
--- /dev/null
+++ b/man/wsrep_sst_mysqldump.1
@@ -0,0 +1,16 @@
+'\" t
+.\"
+.TH "\FBWSREP_SST_MYSQLDUMP\FR" "1" "26 January 2017" "MariaDB 10\&.1" "MariaDB Database System"
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.SH NAME
+wsrep_sst_mysqldump \- mysqldump\-based state snapshot transfer
+.SH DESCRIPTION
+Use: mysqldump-based state snapshot transfer\.
+.PP
+For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/
diff --git a/man/wsrep_sst_rsync.1 b/man/wsrep_sst_rsync.1
new file mode 100644
index 0000000000000..95a80b20821c8
--- /dev/null
+++ b/man/wsrep_sst_rsync.1
@@ -0,0 +1,16 @@
+'\" t
+.\"
+.TH "\FBWSREP_SST_RSYNC\FR" "1" "26 January 2017" "MariaDB 10\&.1" "MariaDB Database System"
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.SH NAME
+wsrep_sst_mysqldump \- rsync-based state snapshot transfer
+.SH DESCRIPTION
+Use: rsync-based state snapshot transfer\.
+.PP
+For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/
diff --git a/man/wsrep_sst_xtrabackup-v2.1 b/man/wsrep_sst_xtrabackup-v2.1
new file mode 100644
index 0000000000000..d61ce803b939d
--- /dev/null
+++ b/man/wsrep_sst_xtrabackup-v2.1
@@ -0,0 +1,16 @@
+'\" t
+.\"
+.TH "\FBWSREP_SST_XTRABACKUP-V2\FR" "1" "26 January 2017" "MariaDB 10\&.1" "MariaDB Database System"
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.SH NAME
+wsrep_sst_xtrabackup-v2 \- xtrabackup\-based state snapshot transfer
+.SH DESCRIPTION
+Use: xtrabackup-based state snapshot transfer\.
+.PP
+For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/
diff --git a/man/wsrep_sst_xtrabackup.1 b/man/wsrep_sst_xtrabackup.1
new file mode 100644
index 0000000000000..9644a29c4ca72
--- /dev/null
+++ b/man/wsrep_sst_xtrabackup.1
@@ -0,0 +1,16 @@
+'\" t
+.\"
+.TH "\FBWSREP_SST_XTRABACKUP\FR" "1" "24 January 2017" "MariaDB 10\&.1" "MariaDB Database System"
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.SH NAME
+wsrep_sst_xtrabackup \- xtrabackup\-based state snapshot transfer
+.SH DESCRIPTION
+Use: xtrabackup-based state snapshot transfer\.
+.PP
+For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/
From 814d0507604192d1da18eb2e30529e5559ce140e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?=
Date: Fri, 10 Mar 2017 14:07:22 +0200
Subject: [PATCH 164/226] MDEV-12215: main.repair_symlink-5543 fails in
buildbot
If openat is present on the system and it tries to open a symlink with
O_NOFOLLOW, we get errno 40.
If openat is not present on the system, we use the alternative open call, with
slightly different logic. IF the symlink doesn't point to a valid file,
we get errno 20. This test uses an invalid symlink on the table t1.MYD.
---
mysql-test/r/repair_symlink-5543.result | 6 ++++--
mysql-test/t/repair_symlink-5543.test | 4 +++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/mysql-test/r/repair_symlink-5543.result b/mysql-test/r/repair_symlink-5543.result
index e827c7b7f7383..f46e5833468e6 100644
--- a/mysql-test/r/repair_symlink-5543.result
+++ b/mysql-test/r/repair_symlink-5543.result
@@ -1,9 +1,11 @@
create table t1 (a int) engine=myisam data directory='MYSQL_TMP_DIR';
insert t1 values (1);
+# Some systems fail with errcode 40, when doing openat, while others
+# don't have openat and fail with errcode 20.
repair table t1;
Table Op Msg_type Msg_text
-test.t1 repair error 40 for record at pos 0
-test.t1 repair Error File 'MYSQL_TMP_DIR/t1.MYD' not found (Errcode: 40 "Too many levels of symbolic links")
+test.t1 repair error 20 for record at pos 0
+test.t1 repair Error File 'MYSQL_TMP_DIR/t1.MYD' not found (Errcode: 20 "")
test.t1 repair status Operation failed
drop table t1;
create table t2 (a int) engine=aria data directory='MYSQL_TMP_DIR';
diff --git a/mysql-test/t/repair_symlink-5543.test b/mysql-test/t/repair_symlink-5543.test
index b83c1aab1f6e8..8259ad82a517b 100644
--- a/mysql-test/t/repair_symlink-5543.test
+++ b/mysql-test/t/repair_symlink-5543.test
@@ -9,7 +9,9 @@
eval create table t1 (a int) engine=myisam data directory='$MYSQL_TMP_DIR';
insert t1 values (1);
--system ln -s $MYSQL_TMP_DIR/foobar5543 $MYSQL_TMP_DIR/t1.TMD
---replace_regex / '.*\/t1/ 'MYSQL_TMP_DIR\/t1/
+--echo # Some systems fail with errcode 40, when doing openat, while others
+--echo # don't have openat and fail with errcode 20.
+--replace_regex / '.*\/t1/ 'MYSQL_TMP_DIR\/t1/ /40/20/ /".*"/""/
repair table t1;
drop table t1;
From 032678ad18498bab01d41779313e48df1990f780 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?=
Date: Fri, 10 Mar 2017 18:33:38 +0200
Subject: [PATCH 165/226] MDEV-12091 Shutdown fails to wait for rollback of
recovered transactions to finish
In the 10.1 InnoDB Plugin, a call os_event_free(buf_flush_event) was
misplaced. The event could be signalled by rollback of resurrected
transactions while shutdown was in progress. This bug was caught
by cmake -DWITH_ASAN testing. This call was only present in the
10.1 InnoDB Plugin, not in other versions, or in XtraDB.
That said, the bug affects all InnoDB versions. Shutdown assumes the
cessation of any page-dirtying activity, including the activity of
the background rollback thread. InnoDB only waited for the background
rollback to finish as part of a slow shutdown (innodb_fast_shutdown=0).
The default is a clean shutdown (innodb_fast_shutdown=1). In a scenario
where InnoDB is killed, restarted, and shut down soon enough, the data
files could become corrupted.
logs_empty_and_mark_files_at_shutdown(): Wait for the
rollback to finish, except if innodb_fast_shutdown=2
(crash-like shutdown) was requested.
trx_rollback_or_clean_recovered(): Before choosing the next
recovered transaction to roll back, terminate early if non-slow
shutdown was initiated. Roll back everything on slow shutdown
(innodb_fast_shutdown=0).
srv_innodb_monitor_mutex: Declare as static, because the mutex
is only used within one module.
After each call to os_event_free(), ensure that the freed event
is not reachable via global variables, by setting the relevant
variables to NULL.
---
storage/innobase/log/log0log.cc | 18 +++++-------------
storage/innobase/srv/srv0srv.cc | 4 ++--
storage/innobase/srv/srv0start.cc | 2 +-
storage/innobase/trx/trx0roll.cc | 19 ++++++++++++-------
storage/xtradb/log/log0log.cc | 17 +++++------------
storage/xtradb/srv/srv0srv.cc | 9 +++++++--
storage/xtradb/trx/trx0roll.cc | 19 ++++++++++++-------
7 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc
index b94a6d30c7d34..63aaaf2efa846 100644
--- a/storage/innobase/log/log0log.cc
+++ b/storage/innobase/log/log0log.cc
@@ -3207,12 +3207,6 @@ logs_empty_and_mark_files_at_shutdown(void)
ib_logf(IB_LOG_LEVEL_INFO, "Starting shutdown...");
- while (srv_fast_shutdown == 0 && trx_rollback_or_clean_is_active) {
- /* we should wait until rollback after recovery end
- for slow shutdown */
- os_thread_sleep(100000);
- }
-
/* Wait until the master thread and all other operations are idle: our
algorithm only works if the server is idle at shutdown */
@@ -3264,7 +3258,8 @@ logs_empty_and_mark_files_at_shutdown(void)
active_thd = srv_get_active_thread_type();
- if (active_thd != SRV_NONE) {
+ if (active_thd != SRV_NONE
+ || (srv_fast_shutdown != 2 && trx_rollback_or_clean_is_active)) {
if (active_thd == SRV_PURGE) {
srv_purge_wakeup();
@@ -3280,11 +3275,9 @@ logs_empty_and_mark_files_at_shutdown(void)
switch (active_thd) {
case SRV_NONE:
- /* This shouldn't happen because we've
- already checked for this case before
- entering the if(). We handle it here
- to avoid a compiler warning. */
- ut_error;
+ thread_type = "rollback of"
+ " recovered transactions";
+ break;
case SRV_WORKER:
thread_type = "worker threads";
break;
@@ -3709,7 +3702,6 @@ log_shutdown(void)
#ifdef UNIV_LOG_ARCHIVE
rw_lock_free(&log_sys->archive_lock);
- os_event_create();
#endif /* UNIV_LOG_ARCHIVE */
#ifdef UNIV_LOG_DEBUG
diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc
index 359369eaf7d5e..723ae838f078f 100644
--- a/storage/innobase/srv/srv0srv.cc
+++ b/storage/innobase/srv/srv0srv.cc
@@ -3,7 +3,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, 2009 Google Inc.
Copyright (c) 2009, Percona Inc.
-Copyright (c) 2013, 2017, MariaDB Corporation Ab. All Rights Reserved.
+Copyright (c) 2013, 2017, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -411,7 +411,7 @@ UNIV_INTERN const char* srv_io_thread_function[SRV_MAX_N_IO_THREADS];
UNIV_INTERN time_t srv_last_monitor_time;
-UNIV_INTERN ib_mutex_t srv_innodb_monitor_mutex;
+static ib_mutex_t srv_innodb_monitor_mutex;
/* Mutex for locking srv_monitor_file. Not created if srv_read_only_mode */
UNIV_INTERN ib_mutex_t srv_monitor_file_mutex;
diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index 127ccb34f52ce..6f606b25324ea 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -3086,7 +3086,7 @@ innobase_shutdown_for_mysql(void)
srv_free();
fil_close();
- /* 4. Free the os_conc_mutex and all os_events and os_mutexes */
+ /* 4. Free all os_events and os_mutexes */
os_sync_free();
diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc
index c65d95a9817f7..8ab9511befcff 100644
--- a/storage/innobase/trx/trx0roll.cc
+++ b/storage/innobase/trx/trx0roll.cc
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2016, 2017, 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
@@ -739,9 +740,9 @@ trx_rollback_or_clean_recovered(
}
if (all) {
- fprintf(stderr,
- "InnoDB: Starting in background the rollback"
- " of uncommitted transactions\n");
+ ib_logf(IB_LOG_LEVEL_INFO,
+ "Starting in background the rollback"
+ " of recovered transactions");
}
/* Note: For XA recovered transactions, we rely on MySQL to
@@ -761,6 +762,12 @@ trx_rollback_or_clean_recovered(
assert_trx_in_rw_list(trx);
+ if (srv_shutdown_state != SRV_SHUTDOWN_NONE
+ && srv_fast_shutdown != 0) {
+ all = FALSE;
+ break;
+ }
+
/* If this function does a cleanup or rollback
then it will release the trx_sys->mutex, therefore
we need to reacquire it before retrying the loop. */
@@ -778,10 +785,8 @@ trx_rollback_or_clean_recovered(
} while (trx != NULL);
if (all) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Rollback of non-prepared"
- " transactions completed\n");
+ ib_logf(IB_LOG_LEVEL_INFO,
+ "Rollback of non-prepared transactions completed");
}
}
diff --git a/storage/xtradb/log/log0log.cc b/storage/xtradb/log/log0log.cc
index 3627d85da6383..5ef9203ce7251 100644
--- a/storage/xtradb/log/log0log.cc
+++ b/storage/xtradb/log/log0log.cc
@@ -3512,12 +3512,6 @@ logs_empty_and_mark_files_at_shutdown(void)
if (log_disable_checkpoint_active)
log_enable_checkpoint();
- while (srv_fast_shutdown == 0 && trx_rollback_or_clean_is_active) {
- /* we should wait until rollback after recovery end
- for slow shutdown */
- os_thread_sleep(100000);
- }
-
/* Wait until the master thread and all other operations are idle: our
algorithm only works if the server is idle at shutdown */
@@ -3569,7 +3563,8 @@ logs_empty_and_mark_files_at_shutdown(void)
active_thd = srv_get_active_thread_type();
- if (active_thd != SRV_NONE) {
+ if (active_thd != SRV_NONE
+ || (srv_fast_shutdown != 2 && trx_rollback_or_clean_is_active)) {
if (active_thd == SRV_PURGE) {
srv_purge_wakeup();
@@ -3585,11 +3580,9 @@ logs_empty_and_mark_files_at_shutdown(void)
switch (active_thd) {
case SRV_NONE:
- /* This shouldn't happen because we've
- already checked for this case before
- entering the if(). We handle it here
- to avoid a compiler warning. */
- ut_error;
+ thread_type = "rollback of"
+ " recovered transactions";
+ break;
case SRV_WORKER:
thread_type = "worker threads";
break;
diff --git a/storage/xtradb/srv/srv0srv.cc b/storage/xtradb/srv/srv0srv.cc
index 72ea6c0d7d589..ffa1e36ebcd85 100644
--- a/storage/xtradb/srv/srv0srv.cc
+++ b/storage/xtradb/srv/srv0srv.cc
@@ -3,7 +3,7 @@
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, 2009 Google Inc.
Copyright (c) 2009, Percona Inc.
-Copyright (c) 2013, 2017, MariaDB Corporation Ab. All Rights Reserved.
+Copyright (c) 2013, 2017, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -543,7 +543,7 @@ UNIV_INTERN const char* srv_io_thread_function[SRV_MAX_N_IO_THREADS];
UNIV_INTERN time_t srv_last_monitor_time;
-UNIV_INTERN ib_mutex_t srv_innodb_monitor_mutex;
+static ib_mutex_t srv_innodb_monitor_mutex;
/* Mutex for locking srv_monitor_file. Not created if srv_read_only_mode */
UNIV_INTERN ib_mutex_t srv_monitor_file_mutex;
@@ -1209,10 +1209,15 @@ srv_free(void)
os_event_free(srv_sys->sys_threads[i].event);
os_event_free(srv_error_event);
+ srv_error_event = NULL;
os_event_free(srv_monitor_event);
+ srv_monitor_event = NULL;
os_event_free(srv_buf_dump_event);
+ srv_buf_dump_event = NULL;
os_event_free(srv_checkpoint_completed_event);
+ srv_checkpoint_completed_event = NULL;
os_event_free(srv_redo_log_tracked_event);
+ srv_redo_log_tracked_event = NULL;
mutex_free(&srv_sys->mutex);
mutex_free(&srv_sys->tasks_mutex);
}
diff --git a/storage/xtradb/trx/trx0roll.cc b/storage/xtradb/trx/trx0roll.cc
index c65d95a9817f7..8ab9511befcff 100644
--- a/storage/xtradb/trx/trx0roll.cc
+++ b/storage/xtradb/trx/trx0roll.cc
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2016, 2017, 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
@@ -739,9 +740,9 @@ trx_rollback_or_clean_recovered(
}
if (all) {
- fprintf(stderr,
- "InnoDB: Starting in background the rollback"
- " of uncommitted transactions\n");
+ ib_logf(IB_LOG_LEVEL_INFO,
+ "Starting in background the rollback"
+ " of recovered transactions");
}
/* Note: For XA recovered transactions, we rely on MySQL to
@@ -761,6 +762,12 @@ trx_rollback_or_clean_recovered(
assert_trx_in_rw_list(trx);
+ if (srv_shutdown_state != SRV_SHUTDOWN_NONE
+ && srv_fast_shutdown != 0) {
+ all = FALSE;
+ break;
+ }
+
/* If this function does a cleanup or rollback
then it will release the trx_sys->mutex, therefore
we need to reacquire it before retrying the loop. */
@@ -778,10 +785,8 @@ trx_rollback_or_clean_recovered(
} while (trx != NULL);
if (all) {
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Rollback of non-prepared"
- " transactions completed\n");
+ ib_logf(IB_LOG_LEVEL_INFO,
+ "Rollback of non-prepared transactions completed");
}
}
From b6a1d6538b4d2001be20fe0d8f470874c744f0a2 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Fri, 10 Mar 2017 16:25:01 +0100
Subject: [PATCH 166/226] compiler warnings
---
storage/connect/ha_connect.cc | 6 +++---
storage/innobase/log/log0crypt.cc | 4 ++--
storage/innobase/os/os0file.cc | 2 +-
storage/xtradb/log/log0crypt.cc | 4 ++--
storage/xtradb/os/os0file.cc | 2 +-
5 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index d1ab18f52d5fb..e34ea620a96e8 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -1034,15 +1034,15 @@ char *GetListOption(PGLOBAL g, const char *opname,
pv= strchr(pk, '=');
if (pv && (!pn || pv < pn)) {
- n= MY_MIN(pv - pk, sizeof(key) - 1);
+ n= MY_MIN(static_cast(pv - pk), sizeof(key) - 1);
memcpy(key, pk, n);
key[n]= 0;
pv++;
- n= MY_MIN((pn ? pn - pv : strlen(pv)), sizeof(val) - 1);
+ n= MY_MIN((pn ? pn - pv : strlen(pv)), sizeof(val) - 1);
memcpy(val, pv, n);
val[n]= 0;
} else {
- n= MY_MIN((pn ? pn - pk : strlen(pk)), sizeof(key) - 1);
+ n= MY_MIN((pn ? pn - pk : strlen(pk)), sizeof(key) - 1);
memcpy(key, pk, n);
key[n]= 0;
val[0]= 0;
diff --git a/storage/innobase/log/log0crypt.cc b/storage/innobase/log/log0crypt.cc
index dc9f3d577e68d..e6b5c845757d7 100644
--- a/storage/innobase/log/log0crypt.cc
+++ b/storage/innobase/log/log0crypt.cc
@@ -145,11 +145,11 @@ log_crypt_print_checkpoint_keys(
if (crypt_info.size()) {
fprintf(stderr,
- "InnoDB: redo log checkpoint: %llu [ chk key ]: ",
+ "InnoDB: redo log checkpoint: " UINT64PF " [ chk key ]: ",
checkpoint_no);
for (size_t i = 0; i < crypt_info.size(); i++) {
struct crypt_info_t* it = &crypt_info[i];
- fprintf(stderr, "[ %llu %u ] ",
+ fprintf(stderr, "[ " UINT64PF " %u ] ",
it->checkpoint_no,
it->key_version);
}
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index e92526ceab07e..efbaee92a7822 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -6280,7 +6280,7 @@ os_file_trim(
srv_use_trim = FALSE;
ib_logf(IB_LOG_LEVEL_WARN,
"fallocate() failed with error %d."
- " start: %llu len: " ULINTPF " payload: " ULINTPF "."
+ " start: " UINT64PF " len: " ULINTPF " payload: " ULINTPF "."
" Disabling fallocate for now.",
errno, off, ulint(trim_len), ulint(len));
diff --git a/storage/xtradb/log/log0crypt.cc b/storage/xtradb/log/log0crypt.cc
index dc9f3d577e68d..e6b5c845757d7 100644
--- a/storage/xtradb/log/log0crypt.cc
+++ b/storage/xtradb/log/log0crypt.cc
@@ -145,11 +145,11 @@ log_crypt_print_checkpoint_keys(
if (crypt_info.size()) {
fprintf(stderr,
- "InnoDB: redo log checkpoint: %llu [ chk key ]: ",
+ "InnoDB: redo log checkpoint: " UINT64PF " [ chk key ]: ",
checkpoint_no);
for (size_t i = 0; i < crypt_info.size(); i++) {
struct crypt_info_t* it = &crypt_info[i];
- fprintf(stderr, "[ %llu %u ] ",
+ fprintf(stderr, "[ " UINT64PF " %u ] ",
it->checkpoint_no,
it->key_version);
}
diff --git a/storage/xtradb/os/os0file.cc b/storage/xtradb/os/os0file.cc
index 7b3b880040767..ed84834e6eaab 100644
--- a/storage/xtradb/os/os0file.cc
+++ b/storage/xtradb/os/os0file.cc
@@ -6394,7 +6394,7 @@ os_file_trim(
srv_use_trim = FALSE;
ib_logf(IB_LOG_LEVEL_WARN,
"fallocate() failed with error %d."
- " start: %llu len: " ULINTPF " payload: " ULINTPF "."
+ " start: " UINT64PF " len: " ULINTPF " payload: " ULINTPF "."
" Disabling fallocate for now.",
errno, off, ulint(trim_len), ulint(len));
From 5fa04aae9ec94428a68ef4f6f681564111933c11 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Wed, 1 Mar 2017 23:52:35 +0100
Subject: [PATCH 167/226] MDEV-11842 Fail to insert on a table where a field
has no default
has_no_default_value() should only fail the insert in the strict mode.
Additionally, don't check for "all fields are given values" twice,
it'll produce duplicate warnings.
---
mysql-test/r/trigger_no_defaults-11698.result | 18 ++++++++++++++++++
mysql-test/t/trigger_no_defaults-11698.test | 15 +++++++++++++++
sql/sql_insert.cc | 9 +++++++--
3 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/mysql-test/r/trigger_no_defaults-11698.result b/mysql-test/r/trigger_no_defaults-11698.result
index 40546cee41d14..936720921805a 100644
--- a/mysql-test/r/trigger_no_defaults-11698.result
+++ b/mysql-test/r/trigger_no_defaults-11698.result
@@ -20,3 +20,21 @@ a b
10 10
0 30
drop table t1;
+set sql_mode=default;
+create table t1 (
+id int(11) not null auto_increment primary key,
+data1 varchar(10) not null,
+data2 varchar(10) not null
+);
+insert into t1 (data2) values ('x');
+Warnings:
+Warning 1364 Field 'data1' doesn't have a default value
+create trigger test_trigger before insert on t1 for each row begin end;
+insert into t1 (data2) values ('y');
+Warnings:
+Warning 1364 Field 'data1' doesn't have a default value
+select * from t1;
+id data1 data2
+1 x
+2 y
+drop table t1;
diff --git a/mysql-test/t/trigger_no_defaults-11698.test b/mysql-test/t/trigger_no_defaults-11698.test
index fab7845ad7d3a..d7e391a8bb29c 100644
--- a/mysql-test/t/trigger_no_defaults-11698.test
+++ b/mysql-test/t/trigger_no_defaults-11698.test
@@ -23,3 +23,18 @@ insert t1 (b) values (20);
insert t1 (b) values (30);
select * from t1;
drop table t1;
+set sql_mode=default;
+
+#
+# MDEV-11842 Fail to insert on a table where a field has no default
+#
+create table t1 (
+ id int(11) not null auto_increment primary key,
+ data1 varchar(10) not null,
+ data2 varchar(10) not null
+);
+insert into t1 (data2) values ('x');
+create trigger test_trigger before insert on t1 for each row begin end;
+insert into t1 (data2) values ('y');
+select * from t1;
+drop table t1;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index f4e0a6a00eb1c..4dacb875abe7b 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -325,7 +325,7 @@ static bool has_no_default_value(THD *thd, Field *field, TABLE_LIST *table_list)
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_NO_DEFAULT_FOR_FIELD,
ER_THD(thd, ER_NO_DEFAULT_FOR_FIELD), field->field_name);
}
- return true;
+ return thd->really_abort_on_warning();
}
return false;
}
@@ -891,7 +891,12 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
if (fields.elements || !value_count || table_list->view != 0)
{
- if (check_that_all_fields_are_given_values(thd, table, table_list))
+ if (table->triggers &&
+ table->triggers->has_triggers(TRG_EVENT_INSERT, TRG_ACTION_BEFORE))
+ {
+ /* BEFORE INSERT triggers exist, the check will be done later, per row */
+ }
+ else if (check_that_all_fields_are_given_values(thd, table, table_list))
{
error= 1;
goto values_loop_end;
From 1c8d2121ab0e9ca0d8a8fccdd85da1072ef30815 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Thu, 2 Mar 2017 06:53:07 +0100
Subject: [PATCH 168/226] don't do vio_description(NULL)
this fixes the crash of innodb.innodb-blob --ps-protocol
---
sql-common/client.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sql-common/client.c b/sql-common/client.c
index 0430946b2ffd1..86c7dea5a5881 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -583,7 +583,7 @@ cli_safe_read(MYSQL *mysql)
if (len == packet_error || len == 0)
{
DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %lu",
- vio_description(net->vio),len));
+ net->vio ? vio_description(net->vio) : NULL, len));
#ifdef MYSQL_SERVER
if (net->vio && (net->last_errno == ER_NET_READ_INTERRUPTED))
return (packet_error);
From 8eb66bc382295003e5da5ff50365d62def30f52d Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Thu, 2 Mar 2017 20:59:29 +0100
Subject: [PATCH 169/226] cleanup: change dd_frm_type() to return the engine
name, not legacy_db_type
this simplifies the code and avoids unnecessary conversions back and forth.
and it works even if the engine is not installed.
---
sql/datadict.cc | 50 +++++++++++++++++++++++++----------------------
sql/datadict.h | 5 ++---
sql/handler.cc | 14 +++++++------
sql/sql_plugin.cc | 7 ++++---
4 files changed, 41 insertions(+), 35 deletions(-)
diff --git a/sql/datadict.cc b/sql/datadict.cc
index 287e8568d9019..ee0d8805f955f 100644
--- a/sql/datadict.cc
+++ b/sql/datadict.cc
@@ -39,25 +39,27 @@ static int read_string(File file, uchar**to, size_t length)
/**
Check type of .frm if we are not going to parse it.
- @param[in] thd The current session.
- @param[in] path path to FRM file.
- @param[out] dbt db_type of the table if FRMTYPE_TABLE, otherwise undefined.
+ @param[in] thd The current session.
+ @param[in] path path to FRM file.
+ @param[in/out] engine_name table engine name (length < NAME_CHAR_LEN)
+
+ engine_name is a LEX_STRING, where engine_name->str must point to
+ a buffer of at least NAME_CHAR_LEN+1 bytes.
@retval FRMTYPE_ERROR error
@retval FRMTYPE_TABLE table
@retval FRMTYPE_VIEW view
*/
-frm_type_enum dd_frm_type(THD *thd, char *path, enum legacy_db_type *dbt)
+frm_type_enum dd_frm_type(THD *thd, char *path, LEX_STRING *engine_name)
{
File file;
uchar header[10]; //"TYPE=VIEW\n" it is 10 characters
size_t error;
frm_type_enum type= FRMTYPE_ERROR;
+ uchar dbt;
DBUG_ENTER("dd_frm_type");
- *dbt= DB_TYPE_UNKNOWN;
-
if ((file= mysql_file_open(key_file_frm, path, O_RDONLY | O_SHARE, MYF(0))) < 0)
DBUG_RETURN(FRMTYPE_ERROR);
error= mysql_file_read(file, (uchar*) header, sizeof(header), MYF(MY_NABP));
@@ -72,17 +74,24 @@ frm_type_enum dd_frm_type(THD *thd, char *path, enum legacy_db_type *dbt)
type= FRMTYPE_TABLE;
- /*
- This is just a check for DB_TYPE. We'll return default unknown type
- if the following test is true (arg #3). This should not have effect
- on return value from this function (default FRMTYPE_TABLE)
- */
- if (!is_binary_frm_header(header))
+ if (!is_binary_frm_header(header) || !engine_name)
goto err;
- *dbt= (enum legacy_db_type) (uint) *(header + 3);
+ engine_name->length= 0;
+ dbt= header[3];
+
+ /* cannot use ha_resolve_by_legacy_type without a THD */
+ if (thd && dbt < DB_TYPE_FIRST_DYNAMIC)
+ {
+ handlerton *ht= ha_resolve_by_legacy_type(thd, (enum legacy_db_type)dbt);
+ if (ht)
+ {
+ *engine_name= hton2plugin[ht->slot]->name;
+ goto err;
+ }
+ }
- if (*dbt >= DB_TYPE_FIRST_DYNAMIC) /* read the true engine name */
+ /* read the true engine name */
{
MY_STAT state;
uchar *frm_image= 0;
@@ -110,15 +119,10 @@ frm_type_enum dd_frm_type(THD *thd, char *path, enum legacy_db_type *dbt)
next_chunk+= connect_string_length + 2;
if (next_chunk + 2 < buff_end)
{
- uint str_db_type_length= uint2korr(next_chunk);
- LEX_STRING name;
- name.str= (char*) next_chunk + 2;
- name.length= str_db_type_length;
- plugin_ref tmp_plugin= ha_resolve_by_name(thd, &name, false);
- if (tmp_plugin)
- *dbt= plugin_data(tmp_plugin, handlerton *)->db_type;
- else
- *dbt= DB_TYPE_UNKNOWN;
+ uint len= uint2korr(next_chunk);
+ if (len <= NAME_CHAR_LEN)
+ strmake(engine_name->str, (char*)next_chunk + 2,
+ engine_name->length= len);
}
}
diff --git a/sql/datadict.h b/sql/datadict.h
index dd80942dacac5..9b180a882f9b1 100644
--- a/sql/datadict.h
+++ b/sql/datadict.h
@@ -35,12 +35,11 @@ enum frm_type_enum
Prefer to use ha_table_exists() instead.
To check whether it's an frm of a view, use dd_frm_is_view().
*/
-frm_type_enum dd_frm_type(THD *thd, char *path, enum legacy_db_type *dbt);
+frm_type_enum dd_frm_type(THD *thd, char *path, LEX_STRING *engine_name);
static inline bool dd_frm_is_view(THD *thd, char *path)
{
- enum legacy_db_type not_used;
- return dd_frm_type(thd, path, ¬_used) == FRMTYPE_VIEW;
+ return dd_frm_type(thd, path, NULL) == FRMTYPE_VIEW;
}
bool dd_recreate_table(THD *thd, const char *db, const char *table_name,
diff --git a/sql/handler.cc b/sql/handler.cc
index 751b6d3ca3cec..17d00ce24864b 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -5025,14 +5025,16 @@ bool ha_table_exists(THD *thd, const char *db, const char *table_name,
bool exists= true;
if (hton)
{
- enum legacy_db_type db_type;
- if (dd_frm_type(thd, path, &db_type) != FRMTYPE_VIEW)
+ char engine_buf[NAME_CHAR_LEN + 1];
+ LEX_STRING engine= { engine_buf, 0 };
+
+ if (dd_frm_type(thd, path, &engine) != FRMTYPE_VIEW)
{
- handlerton *ht= ha_resolve_by_legacy_type(thd, db_type);
- if ((*hton= ht))
+ plugin_ref p= plugin_lock_by_name(thd, &engine, MYSQL_STORAGE_ENGINE_PLUGIN);
+ *hton= p ? plugin_hton(p) : NULL;
+ if (*hton)
// verify that the table really exists
- exists= discover_existence(thd,
- plugin_int_to_ref(hton2plugin[ht->slot]), &args);
+ exists= discover_existence(thd, p, &args);
}
else
*hton= view_pseudo_hton;
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index ed0721feb3b52..4ba9b82cf47d5 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -1646,10 +1646,11 @@ int plugin_init(int *argc, char **argv, int flags)
{
char path[FN_REFLEN + 1];
build_table_filename(path, sizeof(path) - 1, "mysql", "plugin", reg_ext, 0);
- enum legacy_db_type db_type;
- frm_type_enum frm_type= dd_frm_type(NULL, path, &db_type);
+ char engine_name_buf[NAME_CHAR_LEN + 1];
+ LEX_STRING maybe_myisam= { engine_name_buf, 0 };
+ frm_type_enum frm_type= dd_frm_type(NULL, path, &maybe_myisam);
/* if mysql.plugin table is MyISAM - load it right away */
- if (frm_type == FRMTYPE_TABLE && db_type == DB_TYPE_MYISAM)
+ if (frm_type == FRMTYPE_TABLE && !strcasecmp(maybe_myisam.str, "MyISAM"))
{
plugin_load(&tmp_root);
flags|= PLUGIN_INIT_SKIP_PLUGIN_TABLE;
From 25c32c89f14cba402a42a61a8a371ce515610899 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Thu, 2 Mar 2017 14:04:14 +0100
Subject: [PATCH 170/226] trivial cleanup
---
sql/sql_show.cc | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index ae3874506dd60..01132fced1962 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -4430,15 +4430,13 @@ try_acquire_high_prio_shared_mdl_lock(THD *thd, TABLE_LIST *table,
open_tables function for this table
*/
-static int fill_schema_table_from_frm(THD *thd, TABLE_LIST *tables,
+static int fill_schema_table_from_frm(THD *thd, TABLE *table,
ST_SCHEMA_TABLE *schema_table,
LEX_STRING *db_name,
LEX_STRING *table_name,
- enum enum_schema_tables schema_table_idx,
Open_tables_backup *open_tables_state_backup,
bool can_deadlock)
{
- TABLE *table= tables->table;
TABLE_SHARE *share;
TABLE tbl;
TABLE_LIST table_list;
@@ -4796,9 +4794,8 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
if (!(table_open_method & ~OPEN_FRM_ONLY) &&
db_name != &INFORMATION_SCHEMA_NAME)
{
- if (!fill_schema_table_from_frm(thd, tables, schema_table,
+ if (!fill_schema_table_from_frm(thd, table, schema_table,
db_name, table_name,
- schema_table_idx,
&open_tables_state_backup,
can_deadlock))
continue;
From 48b1d175345caa3c644597044751906a04106b91 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Thu, 2 Mar 2017 15:36:18 +0100
Subject: [PATCH 171/226] MDEV-11943 I_S.TABLES inconsistencies with tables
with unknown storage engine
Make SELECT FROM I_S.TABLES behave identically independently
from whether require opening the table in engine or
can be filled with only opening the frm.
In particular, fill_schema_table_from_frm() should not silently skip
frms with unknown engine, but should fill the I_S.TABLES row
with NULLs just like fill_schema_table_by_open() does.
---
mysql-test/r/derived_view.result | 5 ++++
mysql-test/r/drop_bad_db_type.result | 21 ++++++++++++++
mysql-test/r/gis.result | 4 +--
mysql-test/r/join.result | 3 ++
mysql-test/r/partition_column.result | 2 +-
mysql-test/r/ps.result | 9 ++++++
mysql-test/suite/funcs_1/r/is_columns.result | 3 ++
.../suite/funcs_1/r/is_columns_mysql.result | 28 +++++++++++++++++++
.../r/is_columns_mysql_embedded.result | 15 ++++++++++
.../suite/funcs_1/r/is_statistics.result | 3 ++
.../suite/funcs_1/t/is_columns_mysql.test | 1 +
mysql-test/t/drop_bad_db_type.test | 6 ++++
mysql-test/t/gis.test | 4 +--
mysql-test/t/partition_column.test | 2 +-
sql/sql_show.cc | 12 +++++++-
15 files changed, 111 insertions(+), 7 deletions(-)
diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result
index 0a80a16b5080e..bd07fba6d4f66 100644
--- a/mysql-test/r/derived_view.result
+++ b/mysql-test/r/derived_view.result
@@ -1979,6 +1979,11 @@ GROUP BY TABLE_SCHEMA) AS UNIQUES
ON ( COLUMNS.TABLE_SCHEMA = UNIQUES.TABLE_SCHEMA);
COUNT(*) > 0
1
+Warnings:
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1286 Unknown storage engine 'InnoDB'
DROP TABLE t1;
SET SESSION optimizer_switch= @save_optimizer_switch;
#
diff --git a/mysql-test/r/drop_bad_db_type.result b/mysql-test/r/drop_bad_db_type.result
index 6a125cdccf559..9bdf9468d70cb 100644
--- a/mysql-test/r/drop_bad_db_type.result
+++ b/mysql-test/r/drop_bad_db_type.result
@@ -4,6 +4,27 @@ create table t1 (a int) engine=archive;
insert t1 values (1),(2),(3);
flush tables;
uninstall soname 'ha_archive';
+select table_schema, table_name from information_schema.tables where table_name like 't1';
+table_schema test
+table_name t1
+select table_schema, table_name, engine, version from information_schema.tables where table_name like 't1';
+table_schema test
+table_name t1
+engine NULL
+version NULL
+Warnings:
+Level Warning
+Code 1286
+Message Unknown storage engine 'ARCHIVE'
+select table_schema, table_name, engine, row_format from information_schema.tables where table_name like 't1';
+table_schema test
+table_name t1
+engine NULL
+row_format NULL
+Warnings:
+Level Warning
+Code 1286
+Message Unknown storage engine 'ARCHIVE'
install soname 'ha_archive';
t1.ARZ
t1.frm
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result
index 33080509114ff..660a72fc26cfc 100644
--- a/mysql-test/r/gis.result
+++ b/mysql-test/r/gis.result
@@ -1732,7 +1732,7 @@ SPATIAL_REF_SYS CREATE TEMPORARY TABLE `SPATIAL_REF_SYS` (
) ENGINE=MEMORY DEFAULT CHARSET=utf8
create table t1(g GEOMETRY, pt POINT);
create table t2(g LINESTRING, pl POLYGON);
-select * from information_schema.geometry_columns;
+select * from information_schema.geometry_columns where f_table_schema='test';
F_TABLE_CATALOG F_TABLE_SCHEMA F_TABLE_NAME F_GEOMETRY_COLUMN G_TABLE_CATALOG G_TABLE_SCHEMA G_TABLE_NAME G_GEOMETRY_COLUMN STORAGE_TYPE GEOMETRY_TYPE COORD_DIMENSION MAX_PPR SRID
def test t1 def test t1 g 1 0 2 0 0
def test t1 def test t1 pt 1 1 2 0 0
@@ -1741,7 +1741,7 @@ def test t2 def test t2 pl 1 3 2 0 0
drop table t1, t2;
10.1 tests
create table t1(g GEOMETRY(9,4) REF_SYSTEM_ID=101, pt POINT(8,2), pg GEOMETRY REF_SYSTEM_ID=102);
-SELECT SRID from information_schema.geometry_columns WHERE G_TABLE_NAME='t1';
+SELECT SRID from information_schema.geometry_columns WHERE f_table_schema='test' and G_TABLE_NAME='t1';
SRID
101
0
diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result
index d500b38a8dc00..3e39c95fe16eb 100644
--- a/mysql-test/r/join.result
+++ b/mysql-test/r/join.result
@@ -757,6 +757,9 @@ from information_schema.statistics join information_schema.columns using(table_n
TABLE_NAME COLUMN_NAME TABLE_CATALOG TABLE_SCHEMA NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLLATION SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT TABLE_CATALOG TABLE_SCHEMA COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA COLUMN_COMMENT
user Host def mysql 0 mysql PRIMARY 1 A NULL NULL BTREE def mysql NO char 60 180 NULL NULL utf8 utf8_bin char(60) PRI
user User def mysql 0 mysql PRIMARY 2 A NULL NULL BTREE def mysql NO char 80 240 NULL NULL utf8 utf8_bin char(80) PRI
+Warnings:
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1286 Unknown storage engine 'InnoDB'
drop table t1;
drop table t2;
drop table t3;
diff --git a/mysql-test/r/partition_column.result b/mysql-test/r/partition_column.result
index a494656a6a6aa..f18e9b39e1ed9 100644
--- a/mysql-test/r/partition_column.result
+++ b/mysql-test/r/partition_column.result
@@ -540,7 +540,7 @@ a b
drop table t1;
create table t1 as select to_seconds(null) as to_seconds;
select data_type from information_schema.columns
-where column_name='to_seconds';
+where table_schema='test' and column_name='to_seconds';
data_type
int
drop table t1;
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index 1e63ac57768e1..b24fe55e1b227 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -1203,12 +1203,21 @@ prepare my_stmt from @aux;
execute my_stmt;
COUNT(*)
46
+Warnings:
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1286 Unknown storage engine 'InnoDB'
execute my_stmt;
COUNT(*)
46
+Warnings:
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1286 Unknown storage engine 'InnoDB'
execute my_stmt;
COUNT(*)
46
+Warnings:
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1286 Unknown storage engine 'InnoDB'
deallocate prepare my_stmt;
drop procedure if exists p1|
drop table if exists t1|
diff --git a/mysql-test/suite/funcs_1/r/is_columns.result b/mysql-test/suite/funcs_1/r/is_columns.result
index ada8110d229d1..0da7a2bde601a 100644
--- a/mysql-test/suite/funcs_1/r/is_columns.result
+++ b/mysql-test/suite/funcs_1/r/is_columns.result
@@ -97,6 +97,9 @@ COLUMN_COMMENT varchar(1024) NO
SELECT table_catalog, table_schema, table_name, column_name
FROM information_schema.columns WHERE table_catalog IS NULL OR table_catalog <> 'def';
table_catalog table_schema table_name column_name
+Warnings:
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1286 Unknown storage engine 'InnoDB'
###############################################################################
# Testcase 3.2.6.2 + 3.2.6.3: INFORMATION_SCHEMA.COLUMNS accessible information
###############################################################################
diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql.result b/mysql-test/suite/funcs_1/r/is_columns_mysql.result
index 2821e1112e500..3aab87c5ce233 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result
@@ -117,6 +117,20 @@ def mysql index_stats db_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_
def mysql index_stats index_name 3 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
def mysql index_stats prefix_arity 4 NULL NO int NULL NULL 10 0 NULL NULL NULL int(11) unsigned PRI select,insert,update,references
def mysql index_stats table_name 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
+def mysql innodb_index_stats database_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
+def mysql innodb_index_stats index_name 3 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
+def mysql innodb_index_stats last_update 4 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
+def mysql innodb_index_stats sample_size 7 NULL YES bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
+def mysql innodb_index_stats stat_description 8 NULL NO varchar 1024 3072 NULL NULL NULL utf8 utf8_bin varchar(1024) select,insert,update,references
+def mysql innodb_index_stats stat_name 5 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
+def mysql innodb_index_stats stat_value 6 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
+def mysql innodb_index_stats table_name 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
+def mysql innodb_table_stats clustered_index_size 5 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
+def mysql innodb_table_stats database_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
+def mysql innodb_table_stats last_update 3 CURRENT_TIMESTAMP NO timestamp NULL NULL NULL NULL 0 NULL NULL timestamp on update CURRENT_TIMESTAMP select,insert,update,references
+def mysql innodb_table_stats n_rows 4 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
+def mysql innodb_table_stats sum_of_other_index_sizes 6 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select,insert,update,references
+def mysql innodb_table_stats table_name 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) PRI select,insert,update,references
def mysql plugin dl 2 NO varchar 128 384 NULL NULL NULL utf8 utf8_general_ci varchar(128) select,insert,update,references
def mysql plugin name 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) PRI select,insert,update,references
def mysql proc body 11 NULL NO longblob 4294967295 4294967295 NULL NULL NULL NULL NULL longblob select,insert,update,references
@@ -438,6 +452,20 @@ NULL mysql help_topic help_category_id smallint NULL NULL NULL NULL smallint(5)
3.0000 mysql index_stats index_name varchar 64 192 utf8 utf8_bin varchar(64)
NULL mysql index_stats prefix_arity int NULL NULL NULL NULL int(11) unsigned
NULL mysql index_stats avg_frequency decimal NULL NULL NULL NULL decimal(12,4)
+3.0000 mysql innodb_index_stats database_name varchar 64 192 utf8 utf8_bin varchar(64)
+3.0000 mysql innodb_index_stats table_name varchar 64 192 utf8 utf8_bin varchar(64)
+3.0000 mysql innodb_index_stats index_name varchar 64 192 utf8 utf8_bin varchar(64)
+NULL mysql innodb_index_stats last_update timestamp NULL NULL NULL NULL timestamp
+3.0000 mysql innodb_index_stats stat_name varchar 64 192 utf8 utf8_bin varchar(64)
+NULL mysql innodb_index_stats stat_value bigint NULL NULL NULL NULL bigint(20) unsigned
+NULL mysql innodb_index_stats sample_size bigint NULL NULL NULL NULL bigint(20) unsigned
+3.0000 mysql innodb_index_stats stat_description varchar 1024 3072 utf8 utf8_bin varchar(1024)
+3.0000 mysql innodb_table_stats database_name varchar 64 192 utf8 utf8_bin varchar(64)
+3.0000 mysql innodb_table_stats table_name varchar 64 192 utf8 utf8_bin varchar(64)
+NULL mysql innodb_table_stats last_update timestamp NULL NULL NULL NULL timestamp
+NULL mysql innodb_table_stats n_rows bigint NULL NULL NULL NULL bigint(20) unsigned
+NULL mysql innodb_table_stats clustered_index_size bigint NULL NULL NULL NULL bigint(20) unsigned
+NULL mysql innodb_table_stats sum_of_other_index_sizes bigint NULL NULL NULL NULL bigint(20) unsigned
3.0000 mysql plugin name varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 mysql plugin dl varchar 128 384 utf8 utf8_general_ci varchar(128)
3.0000 mysql proc db char 64 192 utf8 utf8_bin char(64)
diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result
index 006ed9d82f26b..a69896c9b5195 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result
@@ -251,6 +251,9 @@ def mysql user Update_priv 6 N NO enum 1 3 NULL NULL NULL utf8 utf8_general_ci e
def mysql user User 2 NO char 80 240 NULL NULL NULL utf8 utf8_bin char(80) PRI
def mysql user x509_issuer 35 NULL NO blob 65535 65535 NULL NULL NULL NULL NULL blob
def mysql user x509_subject 36 NULL NO blob 65535 65535 NULL NULL NULL NULL NULL blob
+Warnings:
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1286 Unknown storage engine 'InnoDB'
##########################################################################
# Show the quotient of CHARACTER_OCTET_LENGTH and CHARACTER_MAXIMUM_LENGTH
##########################################################################
@@ -272,6 +275,9 @@ COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME
1.0000 text utf8 utf8_bin
1.0000 mediumtext utf8 utf8_general_ci
1.0000 text utf8 utf8_general_ci
+Warnings:
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1286 Unknown storage engine 'InnoDB'
SELECT DISTINCT
CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH AS COL_CML,
DATA_TYPE,
@@ -289,6 +295,9 @@ COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME
3.0000 enum utf8 utf8_general_ci
3.0000 set utf8 utf8_general_ci
3.0000 varchar utf8 utf8_general_ci
+Warnings:
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1286 Unknown storage engine 'InnoDB'
SELECT DISTINCT
CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH AS COL_CML,
DATA_TYPE,
@@ -307,6 +316,9 @@ NULL smallint NULL NULL
NULL time NULL NULL
NULL timestamp NULL NULL
NULL tinyint NULL NULL
+Warnings:
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1286 Unknown storage engine 'InnoDB'
--> CHAR(0) is allowed (see manual), and here both CHARACHTER_* values
--> are 0, which is intended behavior, and the result of 0 / 0 IS NULL
SELECT CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH AS COL_CML,
@@ -572,3 +584,6 @@ NULL mysql user max_user_connections int NULL NULL NULL NULL int(11)
3.0000 mysql user is_role enum 1 3 utf8 utf8_general_ci enum('N','Y')
3.0000 mysql user default_role char 80 240 utf8 utf8_bin char(80)
NULL mysql user max_statement_time decimal NULL NULL NULL NULL decimal(12,6)
+Warnings:
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1286 Unknown storage engine 'InnoDB'
diff --git a/mysql-test/suite/funcs_1/r/is_statistics.result b/mysql-test/suite/funcs_1/r/is_statistics.result
index e800d9b63fdaa..7161b80792b70 100644
--- a/mysql-test/suite/funcs_1/r/is_statistics.result
+++ b/mysql-test/suite/funcs_1/r/is_statistics.result
@@ -151,6 +151,9 @@ def mysql time_zone_transition_type mysql PRIMARY
def mysql time_zone_transition_type mysql PRIMARY
def mysql user mysql PRIMARY
def mysql user mysql PRIMARY
+Warnings:
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1286 Unknown storage engine 'InnoDB'
####################################################################################
# Testcase 3.2.14.2 + 3.2.14.3: INFORMATION_SCHEMA.STATISTICS accessible information
####################################################################################
diff --git a/mysql-test/suite/funcs_1/t/is_columns_mysql.test b/mysql-test/suite/funcs_1/t/is_columns_mysql.test
index a844e18f5be22..0566241bd2086 100644
--- a/mysql-test/suite/funcs_1/t/is_columns_mysql.test
+++ b/mysql-test/suite/funcs_1/t/is_columns_mysql.test
@@ -13,6 +13,7 @@
#
--source include/not_embedded.inc
+--source include/have_innodb.inc
let $my_where = WHERE table_schema = 'mysql';
--source suite/funcs_1/datadict/columns.inc
diff --git a/mysql-test/t/drop_bad_db_type.test b/mysql-test/t/drop_bad_db_type.test
index 69e1a889b18c1..00b79dabddf7d 100644
--- a/mysql-test/t/drop_bad_db_type.test
+++ b/mysql-test/t/drop_bad_db_type.test
@@ -15,6 +15,12 @@ insert t1 values (1),(2),(3);
flush tables;
uninstall soname 'ha_archive';
+--vertical_results
+select table_schema, table_name from information_schema.tables where table_name like 't1';
+select table_schema, table_name, engine, version from information_schema.tables where table_name like 't1';
+select table_schema, table_name, engine, row_format from information_schema.tables where table_name like 't1';
+--horizontal_results
+
install soname 'ha_archive';
--list_files $mysqld_datadir/test
drop table t1;
diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test
index 18cfe95b7492a..ea4c024988d2a 100644
--- a/mysql-test/t/gis.test
+++ b/mysql-test/t/gis.test
@@ -1460,12 +1460,12 @@ SHOW CREATE TABLE information_schema.spatial_ref_sys;
create table t1(g GEOMETRY, pt POINT);
create table t2(g LINESTRING, pl POLYGON);
-select * from information_schema.geometry_columns;
+select * from information_schema.geometry_columns where f_table_schema='test';
drop table t1, t2;
--echo 10.1 tests
create table t1(g GEOMETRY(9,4) REF_SYSTEM_ID=101, pt POINT(8,2), pg GEOMETRY REF_SYSTEM_ID=102);
-SELECT SRID from information_schema.geometry_columns WHERE G_TABLE_NAME='t1';
+SELECT SRID from information_schema.geometry_columns WHERE f_table_schema='test' and G_TABLE_NAME='t1';
drop table t1;
-- echo # Expect an int(1) column to be created
diff --git a/mysql-test/t/partition_column.test b/mysql-test/t/partition_column.test
index 95a2be3639567..be34e4eac6317 100644
--- a/mysql-test/t/partition_column.test
+++ b/mysql-test/t/partition_column.test
@@ -398,7 +398,7 @@ drop table t1;
create table t1 as select to_seconds(null) as to_seconds;
select data_type from information_schema.columns
-where column_name='to_seconds';
+where table_schema='test' and column_name='to_seconds';
drop table t1;
--error ER_PARSE_ERROR
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 01132fced1962..0ef7099708964 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -4518,7 +4518,17 @@ static int fill_schema_table_from_frm(THD *thd, TABLE *table,
share= tdc_acquire_share_shortlived(thd, &table_list, GTS_TABLE | GTS_VIEW);
if (!share)
{
- res= 0;
+ if (thd->get_stmt_da()->sql_errno() == ER_NO_SUCH_TABLE ||
+ thd->get_stmt_da()->sql_errno() == ER_WRONG_OBJECT)
+ {
+ res= 0;
+ }
+ else
+ {
+ table_list.table= &tbl;
+ res= schema_table->process_table(thd, &table_list, table,
+ true, db_name, table_name);
+ }
goto end;
}
From 8f1ca5e311bda92d4e901aae8ec5c47597d0f934 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Fri, 3 Mar 2017 15:27:19 +0100
Subject: [PATCH 172/226] MDEV-11943 I_S.TABLES inconsistencies with tables
with unknown storage engine
Try harder to show the table's engine.
If the table's engine is not loaded, the table won't open.
But we can still read the engine name from frm as a string.
---
mysql-test/r/drop_bad_db_type.result | 4 ++--
sql/sql_show.cc | 35 ++++++++++++++++++++++++----
2 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/mysql-test/r/drop_bad_db_type.result b/mysql-test/r/drop_bad_db_type.result
index 9bdf9468d70cb..de22373e0fd76 100644
--- a/mysql-test/r/drop_bad_db_type.result
+++ b/mysql-test/r/drop_bad_db_type.result
@@ -10,7 +10,7 @@ table_name t1
select table_schema, table_name, engine, version from information_schema.tables where table_name like 't1';
table_schema test
table_name t1
-engine NULL
+engine ARCHIVE
version NULL
Warnings:
Level Warning
@@ -19,7 +19,7 @@ Message Unknown storage engine 'ARCHIVE'
select table_schema, table_name, engine, row_format from information_schema.tables where table_name like 't1';
table_schema test
table_name t1
-engine NULL
+engine ARCHIVE
row_format NULL
Warnings:
Level Warning
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 0ef7099708964..e915a78d54acb 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -4056,6 +4056,22 @@ make_table_name_list(THD *thd, Dynamic_array *table_names,
}
+static void get_table_engine_for_i_s(THD *thd, char *buf, TABLE_LIST *tl,
+ LEX_STRING *db, LEX_STRING *table)
+{
+ LEX_STRING engine_name= { buf, 0 };
+
+ if (thd->get_stmt_da()->sql_errno() == ER_UNKNOWN_STORAGE_ENGINE)
+ {
+ char path[FN_REFLEN];
+ build_table_filename(path, sizeof(path) - 1,
+ db->str, table->str, reg_ext, 0);
+ if (dd_frm_type(thd, path, &engine_name) == FRMTYPE_TABLE)
+ tl->option= engine_name.str;
+ }
+}
+
+
/**
Fill I_S table with data obtained by performing full-blown table open.
@@ -4126,9 +4142,9 @@ fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys,
/*
Since make_table_list() might change database and table name passed
- to it we create copies of orig_db_name and orig_table_name here.
- These copies are used for make_table_list() while unaltered values
- are passed to process_table() functions.
+ to it (if lower_case_table_names) we create copies of orig_db_name and
+ orig_table_name here. These copies are used for make_table_list()
+ while unaltered values are passed to process_table() functions.
*/
if (!thd->make_lex_string(&db_name,
orig_db_name->str, orig_db_name->length) ||
@@ -4215,6 +4231,10 @@ fill_schema_table_by_open(THD *thd, bool is_show_fields_or_keys,
}
else
{
+ char buf[NAME_CHAR_LEN + 1];
+ if (thd->is_error())
+ get_table_engine_for_i_s(thd, buf, table_list, &db_name, &table_name);
+
result= schema_table->process_table(thd, table_list,
table, result,
orig_db_name,
@@ -4525,7 +4545,9 @@ static int fill_schema_table_from_frm(THD *thd, TABLE *table,
}
else
{
- table_list.table= &tbl;
+ char buf[NAME_CHAR_LEN + 1];
+ get_table_engine_for_i_s(thd, buf, &table_list, db_name, table_name);
+
res= schema_table->process_table(thd, &table_list, table,
true, db_name, table_name);
}
@@ -4939,6 +4961,11 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
else
table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs);
+ if (tables->option)
+ {
+ table->field[4]->store(tables->option, strlen(tables->option), cs);
+ table->field[4]->set_notnull();
+ }
goto err;
}
From c372388e4862938037f98b6e4936bc61872354dd Mon Sep 17 00:00:00 2001
From: Hartmut Holzgraefe
Date: Tue, 7 Feb 2017 22:56:28 +0100
Subject: [PATCH 173/226] make mysql_upgrade try to install missing storage
engine plugins (MDEV-11942)
---
client/mysql_upgrade.c | 50 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 48 insertions(+), 2 deletions(-)
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index 0594af39451ac..a1dcba91aa2c4 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -756,7 +756,6 @@ static void print_conn_args(const char *tool_name)
verbose("Running '%s with default connection arguments", tool_name);
}
-
/*
Check and upgrade(if necessary) all tables
in the server using "mysqlcheck --check-upgrade .."
@@ -926,6 +925,52 @@ static void print_line(char* line)
}
+/*
+ Check for entries with "Unknown storage engine" in I_S.TABLES,
+ try to load plugins for these tables if available (MDEV-11942)
+*/
+static int run_mysqlcheck_engines(void)
+{
+ DYNAMIC_STRING ds_query;
+ DYNAMIC_STRING ds_result;
+
+ /* Trying to identify existing tables with unknown storage engine
+ Does not work with all engine types yet, and doesn't produce
+ results for BLACKHOLE without the dummy "WHERE row_format IS NULL"
+ condition yet. See MDEV-11943 */
+ const char *query = "SELECT DISTINCT LOWER(REPLACE(REPLACE(table_comment, 'Unknown storage engine ', ''), '\\'', '')) AS engine FROM information_schema.tables WHERE row_format IS NULL AND table_comment LIKE 'Unknown storage engine%'";
+
+ if (init_dynamic_string(&ds_query, "", 512, 512))
+ die("Out of memory");
+
+ if (init_dynamic_string(&ds_result, "", 512, 512))
+ die("Out of memory");
+
+ verbose("Checking for tables with unknown storage engine");
+
+ run_query(query, &ds_result, TRUE);
+
+ {
+ char *line= ds_result.str;
+ if (line && *line) {
+ do
+ {
+ line[strlen(line)-1]='\0';
+ verbose("installing missing plugin for '%s' storage engine", line);
+
+ dynstr_set(&ds_query, "INSTALL SONAME 'ha_");
+ dynstr_append(&ds_query, line); // we simply assume SONAME=ha_ENGINENAME
+ dynstr_append(&ds_query, "'");
+
+ if (run_query(ds_query.str, NULL, TRUE)) {
+ fprintf(stderr, "... can't install plugin 'ha_%s'\n", line);
+ }
+ } while ((line= get_line(line)) && *line);
+ }
+ }
+}
+
+
/*
Update all system tables in MySQL Server to current
version using "mysql" to execute all the SQL commands
@@ -1131,7 +1176,8 @@ int main(int argc, char **argv)
/*
Run "mysqlcheck" and "mysql_fix_privilege_tables.sql"
*/
- if (run_mysqlcheck_upgrade(TRUE) ||
+ if (run_mysqlcheck_engines() ||
+ run_mysqlcheck_upgrade(TRUE) ||
run_mysqlcheck_views() ||
run_sql_fix_privilege_tables() ||
run_mysqlcheck_fixnames() ||
From 3d06f0f72cbabe833036f920e9452cd6ef46e5aa Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Sat, 4 Mar 2017 17:17:00 +0100
Subject: [PATCH 174/226] MDEV-11942 BLACKHOLE is no longer active in 10.1 by
default, mysql_upgrade not handling the situation
fix the patch. add tests
---
client/mysql_upgrade.c | 92 +++---
mysql-test/r/ctype_upgrade.result | 26 +-
mysql-test/r/log_tables_upgrade.result | 13 +-
mysql-test/r/mysql_upgrade-6984.result | 13 +-
mysql-test/r/mysql_upgrade.result | 130 +++++----
mysql-test/r/mysql_upgrade_no_innodb.result | 13 +-
mysql-test/r/mysql_upgrade_noengine.result | 297 ++++++++++++++++++++
mysql-test/r/mysql_upgrade_ssl.result | 13 +-
mysql-test/r/mysql_upgrade_view.result | 39 +--
mysql-test/t/mysql_upgrade_noengine.test | 56 ++++
10 files changed, 546 insertions(+), 146 deletions(-)
create mode 100644 mysql-test/r/mysql_upgrade_noengine.result
create mode 100644 mysql-test/t/mysql_upgrade_noengine.test
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index a1dcba91aa2c4..ee63fda2e39aa 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -37,7 +37,7 @@
#endif
static int phase = 0;
-static int phases_total = 6;
+static const int phases_total = 7;
static char mysql_path[FN_REFLEN];
static char mysqlcheck_path[FN_REFLEN];
@@ -69,6 +69,8 @@ static char **defaults_argv;
static my_bool not_used; /* Can't use GET_BOOL without a value pointer */
+char upgrade_from_version[sizeof("10.20.456-MariaDB")+1];
+
static my_bool opt_write_binlog;
#define OPT_SILENT OPT_MAX_CLIENT_OPTION
@@ -675,7 +677,6 @@ static int upgrade_already_done(void)
{
FILE *in;
char upgrade_info_file[FN_REFLEN]= {0};
- char buf[sizeof(MYSQL_SERVER_VERSION)+1];
if (get_upgrade_info_file_name(upgrade_info_file))
return 0; /* Could not get filename => not sure */
@@ -683,15 +684,15 @@ static int upgrade_already_done(void)
if (!(in= my_fopen(upgrade_info_file, O_RDONLY, MYF(0))))
return 0; /* Could not open file => not sure */
- bzero(buf, sizeof(buf));
- if (!fgets(buf, sizeof(buf), in))
+ bzero(upgrade_from_version, sizeof(upgrade_from_version));
+ if (!fgets(upgrade_from_version, sizeof(upgrade_from_version), in))
{
/* Ignore, will be detected by strncmp() below */
}
my_fclose(in, MYF(0));
- return (strncmp(buf, MYSQL_SERVER_VERSION,
+ return (strncmp(upgrade_from_version, MYSQL_SERVER_VERSION,
sizeof(MYSQL_SERVER_VERSION)-1)==0);
}
@@ -924,24 +925,48 @@ static void print_line(char* line)
fputc('\n', stderr);
}
+static my_bool from_before_10_1()
+{
+ my_bool ret= TRUE;
+ DYNAMIC_STRING ds_events_struct;
+
+ if (upgrade_from_version[0])
+ {
+ return upgrade_from_version[1] == '.' ||
+ strncmp(upgrade_from_version, "10.1.", 5) < 0;
+ }
+
+ if (init_dynamic_string(&ds_events_struct, NULL, 2048, 2048))
+ die("Out of memory");
+
+ if (run_query("show create table mysql.user", &ds_events_struct, FALSE) ||
+ strstr(ds_events_struct.str, "default_role") != NULL)
+ ret= FALSE;
+ else
+ verbose("Upgrading from a version before MariaDB-10.1");
+
+ dynstr_free(&ds_events_struct);
+ return ret;
+}
+
/*
Check for entries with "Unknown storage engine" in I_S.TABLES,
try to load plugins for these tables if available (MDEV-11942)
*/
-static int run_mysqlcheck_engines(void)
+static int install_used_engines(void)
{
- DYNAMIC_STRING ds_query;
+ char buf[512];
DYNAMIC_STRING ds_result;
+ const char *query = "SELECT DISTINCT LOWER(engine) FROM information_schema.tables"
+ " WHERE table_comment LIKE 'Unknown storage engine%'";
- /* Trying to identify existing tables with unknown storage engine
- Does not work with all engine types yet, and doesn't produce
- results for BLACKHOLE without the dummy "WHERE row_format IS NULL"
- condition yet. See MDEV-11943 */
- const char *query = "SELECT DISTINCT LOWER(REPLACE(REPLACE(table_comment, 'Unknown storage engine ', ''), '\\'', '')) AS engine FROM information_schema.tables WHERE row_format IS NULL AND table_comment LIKE 'Unknown storage engine%'";
-
- if (init_dynamic_string(&ds_query, "", 512, 512))
- die("Out of memory");
+ if (opt_systables_only || !from_before_10_1())
+ {
+ verbose("Phase %d/%d: Installing used storage engines... Skipped", ++phase, phases_total);
+ return 0;
+ }
+ verbose("Phase %d/%d: Installing used storage engines", ++phase, phases_total);
if (init_dynamic_string(&ds_result, "", 512, 512))
die("Out of memory");
@@ -950,24 +975,28 @@ static int run_mysqlcheck_engines(void)
run_query(query, &ds_result, TRUE);
+ if (ds_result.length)
{
- char *line= ds_result.str;
- if (line && *line) {
- do
- {
- line[strlen(line)-1]='\0';
- verbose("installing missing plugin for '%s' storage engine", line);
+ char *line= ds_result.str, *next=get_line(line);
+ do
+ {
+ if (next[-1] == '\n')
+ next[-1]=0;
- dynstr_set(&ds_query, "INSTALL SONAME 'ha_");
- dynstr_append(&ds_query, line); // we simply assume SONAME=ha_ENGINENAME
- dynstr_append(&ds_query, "'");
+ verbose("installing plugin for '%s' storage engine", line);
- if (run_query(ds_query.str, NULL, TRUE)) {
- fprintf(stderr, "... can't install plugin 'ha_%s'\n", line);
- }
- } while ((line= get_line(line)) && *line);
- }
+ // we simply assume soname=ha_enginename
+ strxnmov(buf, sizeof(buf)-1, "install soname 'ha_", line, "'", NULL);
+
+
+ if (run_query(buf, NULL, TRUE))
+ fprintf(stderr, "... can't %s\n", buf);
+ line=next;
+ next=get_line(line);
+ } while (*line);
}
+ dynstr_free(&ds_result);
+ return 0;
}
@@ -1176,8 +1205,8 @@ int main(int argc, char **argv)
/*
Run "mysqlcheck" and "mysql_fix_privilege_tables.sql"
*/
- if (run_mysqlcheck_engines() ||
- run_mysqlcheck_upgrade(TRUE) ||
+ if (run_mysqlcheck_upgrade(TRUE) ||
+ install_used_engines() ||
run_mysqlcheck_views() ||
run_sql_fix_privilege_tables() ||
run_mysqlcheck_fixnames() ||
@@ -1200,4 +1229,3 @@ int main(int argc, char **argv)
my_end(my_end_arg);
exit(0);
}
-
diff --git a/mysql-test/r/ctype_upgrade.result b/mysql-test/r/ctype_upgrade.result
index b317be42d5cb6..53cb858035bc4 100644
--- a/mysql-test/r/ctype_upgrade.result
+++ b/mysql-test/r/ctype_upgrade.result
@@ -227,7 +227,7 @@ DROP TABLE mysql050614_xxx_croatian_ci;
# Checking mysql_upgrade
#
# Running mysql_upgrade
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -258,10 +258,11 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
-Phase 2/6: Fixing views
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names
-Phase 5/6: Checking and upgrading tables
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -280,11 +281,11 @@ test.maria050313_ucs2_croatian_ci_def OK
test.maria050313_utf8_croatian_ci OK
test.maria050533_xxx_croatian_ci OK
test.maria100004_xxx_croatian_ci OK
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
# Running mysql_upgrade for the second time
# This should report OK for all tables
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -315,10 +316,11 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
-Phase 2/6: Fixing views
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names
-Phase 5/6: Checking and upgrading tables
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -331,7 +333,7 @@ test.maria050313_utf8_croatian_ci OK
test.maria050533_xxx_croatian_ci OK
test.maria100004_xxx_croatian_ci OK
test.mysql050614_xxx_croatian_ci OK
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
SHOW CREATE TABLE maria050313_ucs2_croatian_ci_def;
Table Create Table
diff --git a/mysql-test/r/log_tables_upgrade.result b/mysql-test/r/log_tables_upgrade.result
index 6cbb25bd1d4dc..a56d067c2cdb3 100644
--- a/mysql-test/r/log_tables_upgrade.result
+++ b/mysql-test/r/log_tables_upgrade.result
@@ -11,7 +11,7 @@ Table Op Msg_type Msg_text
test.bug49823 repair status OK
RENAME TABLE general_log TO renamed_general_log;
RENAME TABLE test.bug49823 TO general_log;
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -43,10 +43,11 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
-Phase 2/6: Fixing views
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names
-Phase 5/6: Checking and upgrading tables
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -54,7 +55,7 @@ mtr.global_suppressions OK
mtr.test_suppressions OK
performance_schema
test
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
DROP TABLE general_log;
RENAME TABLE renamed_general_log TO general_log;
diff --git a/mysql-test/r/mysql_upgrade-6984.result b/mysql-test/r/mysql_upgrade-6984.result
index 6aea4806ddb62..dacea61d09474 100644
--- a/mysql-test/r/mysql_upgrade-6984.result
+++ b/mysql-test/r/mysql_upgrade-6984.result
@@ -1,5 +1,5 @@
update mysql.user set password=password("foo") where user='root';
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -42,10 +42,11 @@ error : Corrupt
mysql.innodb_table_stats
Error : Unknown storage engine 'InnoDB'
error : Corrupt
-Phase 2/6: Fixing views
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names
-Phase 5/6: Checking and upgrading tables
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -53,7 +54,7 @@ mtr.global_suppressions OK
mtr.test_suppressions OK
performance_schema
test
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
update mysql.user set password='' where user='root';
flush privileges;
diff --git a/mysql-test/r/mysql_upgrade.result b/mysql-test/r/mysql_upgrade.result
index d10e042729ffe..467250559525e 100644
--- a/mysql-test/r/mysql_upgrade.result
+++ b/mysql-test/r/mysql_upgrade.result
@@ -1,6 +1,6 @@
set sql_mode="";
Run mysql_upgrade once
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -31,10 +31,11 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
-Phase 2/6: Fixing views
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names
-Phase 5/6: Checking and upgrading tables
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -42,12 +43,12 @@ mtr.global_suppressions OK
mtr.test_suppressions OK
performance_schema
test
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
Run it again - should say already completed
This installation of MySQL is already upgraded to VERSION, use --force if you still need to run mysql_upgrade
Force should run it regardless of whether it has been run before
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -78,10 +79,11 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
-Phase 2/6: Fixing views
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names
-Phase 5/6: Checking and upgrading tables
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -89,12 +91,12 @@ mtr.global_suppressions OK
mtr.test_suppressions OK
performance_schema
test
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
CREATE USER mysqltest1@'%' IDENTIFIED by 'sakila';
GRANT ALL ON *.* TO mysqltest1@'%';
Run mysql_upgrade with password protected account
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -125,10 +127,11 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
-Phase 2/6: Fixing views
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names
-Phase 5/6: Checking and upgrading tables
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -136,7 +139,7 @@ mtr.global_suppressions OK
mtr.test_suppressions OK
performance_schema
test
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
DROP USER mysqltest1@'%';
Version check failed. Got the following error when calling the 'mysql' command line client
@@ -146,7 +149,7 @@ Run mysql_upgrade with a non existing server socket
mysqlcheck: Got error: 2005: Unknown MySQL server host 'not_existing_host' (errno) when trying to connect
FATAL ERROR: Upgrade failed
set GLOBAL sql_mode='STRICT_ALL_TABLES,ANSI_QUOTES,NO_ZERO_DATE';
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -177,10 +180,11 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
-Phase 2/6: Fixing views
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names
-Phase 5/6: Checking and upgrading tables
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -188,7 +192,7 @@ mtr.global_suppressions OK
mtr.test_suppressions OK
performance_schema
test
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
set GLOBAL sql_mode=default;
#
@@ -199,7 +203,7 @@ CREATE PROCEDURE testproc() BEGIN END;
UPDATE mysql.proc SET character_set_client = NULL WHERE name LIKE 'testproc';
UPDATE mysql.proc SET collation_connection = NULL WHERE name LIKE 'testproc';
UPDATE mysql.proc SET db_collation = NULL WHERE name LIKE 'testproc';
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -230,10 +234,11 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
-Phase 2/6: Fixing views
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names
-Phase 5/6: Checking and upgrading tables
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -241,7 +246,7 @@ mtr.global_suppressions OK
mtr.test_suppressions OK
performance_schema
test
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
CALL testproc();
DROP PROCEDURE testproc;
@@ -255,7 +260,7 @@ WARNING: NULL values of the 'db_collation' column ('mysql.proc' table) have been
GRANT USAGE ON *.* TO 'user3'@'%';
GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%';
Run mysql_upgrade with all privileges on a user
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -286,10 +291,11 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
-Phase 2/6: Fixing views
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names
-Phase 5/6: Checking and upgrading tables
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -297,7 +303,7 @@ mtr.global_suppressions OK
mtr.test_suppressions OK
performance_schema
test
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
SHOW GRANTS FOR 'user3'@'%';
Grants for user3@%
@@ -306,7 +312,7 @@ GRANT ALL PRIVILEGES ON `roelt`.`test2` TO 'user3'@'%'
DROP USER 'user3'@'%';
End of 5.1 tests
The --upgrade-system-tables option was used, user tables won't be touched.
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -337,11 +343,12 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
-Phase 2/6: Fixing views... Skipped
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names ... Skipped
-Phase 5/6: Checking and upgrading tables... Skipped
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views... Skipped
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names ... Skipped
+Phase 6/7: Checking and upgrading tables... Skipped
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
#
# Bug#11827359 60223: MYSQL_UPGRADE PROBLEM WITH OPTION
@@ -349,7 +356,7 @@ OK
#
# Droping the previously created mysql_upgrade_info file..
# Running mysql_upgrade with --skip-write-binlog..
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -380,10 +387,11 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
-Phase 2/6: Fixing views
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names
-Phase 5/6: Checking and upgrading tables
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -391,7 +399,7 @@ mtr.global_suppressions OK
mtr.test_suppressions OK
performance_schema
test
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
#
# Bug #21489398: MYSQL_UPGRADE: FATAL ERROR: UPGRADE FAILED - IMPROVE ERROR
@@ -412,7 +420,7 @@ GRANT INSERT ON mysql.user TO very_long_user_name_number_2;
GRANT UPDATE (User) ON mysql.db TO very_long_user_name_number_1;
GRANT UPDATE (User) ON mysql.db TO very_long_user_name_number_2;
CREATE PROCEDURE test.pr() BEGIN END;
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -443,10 +451,11 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
-Phase 2/6: Fixing views
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names
-Phase 5/6: Checking and upgrading tables
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -454,7 +463,7 @@ mtr.global_suppressions OK
mtr.test_suppressions OK
performance_schema
test
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
SELECT definer FROM mysql.proc WHERE db = 'test' AND name = 'pr';
definer
@@ -470,7 +479,7 @@ set sql_mode=default;
create table test.t1(a int) engine=MyISAM;
# Trying to enforce InnoDB for all tables
SET GLOBAL enforce_storage_engine=InnoDB;
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -501,10 +510,11 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
-Phase 2/6: Fixing views
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names
-Phase 5/6: Checking and upgrading tables
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -513,7 +523,7 @@ mtr.test_suppressions OK
performance_schema
test
test.t1 OK
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
# Should return 2
SELECT count(*) FROM information_schema.tables where ENGINE="InnoDB";
diff --git a/mysql-test/r/mysql_upgrade_no_innodb.result b/mysql-test/r/mysql_upgrade_no_innodb.result
index acbca13158727..6ad818278f8e0 100644
--- a/mysql-test/r/mysql_upgrade_no_innodb.result
+++ b/mysql-test/r/mysql_upgrade_no_innodb.result
@@ -1,5 +1,5 @@
The --upgrade-system-tables option was used, user tables won't be touched.
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -42,9 +42,10 @@ error : Corrupt
mysql.innodb_table_stats
Error : Unknown storage engine 'InnoDB'
error : Corrupt
-Phase 2/6: Fixing views... Skipped
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names ... Skipped
-Phase 5/6: Checking and upgrading tables... Skipped
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views... Skipped
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names ... Skipped
+Phase 6/7: Checking and upgrading tables... Skipped
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
diff --git a/mysql-test/r/mysql_upgrade_noengine.result b/mysql-test/r/mysql_upgrade_noengine.result
new file mode 100644
index 0000000000000..09e705abb69db
--- /dev/null
+++ b/mysql-test/r/mysql_upgrade_noengine.result
@@ -0,0 +1,297 @@
+install soname 'ha_blackhole';
+install soname 'ha_archive';
+create table t1 (a int) engine=blackhole;
+create table t2 (a int) engine=archive;
+select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test';
+table_catalog def
+table_schema test
+table_name t1
+table_type BASE TABLE
+engine BLACKHOLE
+row_format Fixed
+table_rows 0
+data_length 0
+table_comment
+table_catalog def
+table_schema test
+table_name t2
+table_type BASE TABLE
+engine ARCHIVE
+row_format Compressed
+table_rows 0
+data_length 521
+table_comment
+flush tables;
+uninstall plugin blackhole;
+uninstall plugin archive;
+select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test';
+table_catalog def
+table_schema test
+table_name t1
+table_type BASE TABLE
+engine BLACKHOLE
+row_format NULL
+table_rows NULL
+data_length NULL
+table_comment Unknown storage engine 'BLACKHOLE'
+table_catalog def
+table_schema test
+table_name t2
+table_type BASE TABLE
+engine ARCHIVE
+row_format NULL
+table_rows NULL
+data_length NULL
+table_comment Unknown storage engine 'ARCHIVE'
+Warnings:
+Level Warning
+Code 1286
+Message Unknown storage engine 'BLACKHOLE'
+Level Warning
+Code 1286
+Message Unknown storage engine 'ARCHIVE'
+Phase 1/7: Checking and upgrading mysql database
+Processing databases
+mysql
+mysql.column_stats OK
+mysql.columns_priv OK
+mysql.db OK
+mysql.event OK
+mysql.func OK
+mysql.gtid_slave_pos OK
+mysql.help_category OK
+mysql.help_keyword OK
+mysql.help_relation OK
+mysql.help_topic OK
+mysql.host OK
+mysql.index_stats OK
+mysql.innodb_index_stats OK
+mysql.innodb_table_stats OK
+mysql.plugin OK
+mysql.proc OK
+mysql.procs_priv OK
+mysql.proxies_priv OK
+mysql.roles_mapping OK
+mysql.servers OK
+mysql.table_stats OK
+mysql.tables_priv OK
+mysql.time_zone OK
+mysql.time_zone_leap_second OK
+mysql.time_zone_name OK
+mysql.time_zone_transition OK
+mysql.time_zone_transition_type OK
+mysql.user OK
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
+Processing databases
+information_schema
+mtr
+mtr.global_suppressions OK
+mtr.test_suppressions OK
+performance_schema
+test
+test.t1
+Error : Unknown storage engine 'BLACKHOLE'
+error : Corrupt
+test.t2
+Error : Unknown storage engine 'ARCHIVE'
+error : Corrupt
+
+Repairing tables
+test.t1
+Error : Unknown storage engine 'BLACKHOLE'
+error : Corrupt
+test.t2
+Error : Unknown storage engine 'ARCHIVE'
+error : Corrupt
+Phase 7/7: Running 'FLUSH PRIVILEGES'
+OK
+select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test';
+table_catalog def
+table_schema test
+table_name t1
+table_type BASE TABLE
+engine BLACKHOLE
+row_format NULL
+table_rows NULL
+data_length NULL
+table_comment Unknown storage engine 'BLACKHOLE'
+table_catalog def
+table_schema test
+table_name t2
+table_type BASE TABLE
+engine ARCHIVE
+row_format NULL
+table_rows NULL
+data_length NULL
+table_comment Unknown storage engine 'ARCHIVE'
+Warnings:
+Level Warning
+Code 1286
+Message Unknown storage engine 'BLACKHOLE'
+Level Warning
+Code 1286
+Message Unknown storage engine 'ARCHIVE'
+alter table mysql.user drop column default_role, drop column max_statement_time;
+Phase 1/7: Checking and upgrading mysql database
+Processing databases
+mysql
+mysql.column_stats OK
+mysql.columns_priv OK
+mysql.db OK
+mysql.event OK
+mysql.func OK
+mysql.gtid_slave_pos OK
+mysql.help_category OK
+mysql.help_keyword OK
+mysql.help_relation OK
+mysql.help_topic OK
+mysql.host OK
+mysql.index_stats OK
+mysql.innodb_index_stats OK
+mysql.innodb_table_stats OK
+mysql.plugin OK
+mysql.proc OK
+mysql.procs_priv OK
+mysql.proxies_priv OK
+mysql.roles_mapping OK
+mysql.servers OK
+mysql.table_stats OK
+mysql.tables_priv OK
+mysql.time_zone OK
+mysql.time_zone_leap_second OK
+mysql.time_zone_name OK
+mysql.time_zone_transition OK
+mysql.time_zone_transition_type OK
+mysql.user OK
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
+Processing databases
+information_schema
+mtr
+mtr.global_suppressions OK
+mtr.test_suppressions OK
+performance_schema
+test
+test.t1
+Error : Unknown storage engine 'BLACKHOLE'
+error : Corrupt
+test.t2
+Error : Unknown storage engine 'ARCHIVE'
+error : Corrupt
+
+Repairing tables
+test.t1
+Error : Unknown storage engine 'BLACKHOLE'
+error : Corrupt
+test.t2
+Error : Unknown storage engine 'ARCHIVE'
+error : Corrupt
+Phase 7/7: Running 'FLUSH PRIVILEGES'
+OK
+select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test';
+table_catalog def
+table_schema test
+table_name t1
+table_type BASE TABLE
+engine BLACKHOLE
+row_format NULL
+table_rows NULL
+data_length NULL
+table_comment Unknown storage engine 'BLACKHOLE'
+table_catalog def
+table_schema test
+table_name t2
+table_type BASE TABLE
+engine ARCHIVE
+row_format NULL
+table_rows NULL
+data_length NULL
+table_comment Unknown storage engine 'ARCHIVE'
+Warnings:
+Level Warning
+Code 1286
+Message Unknown storage engine 'BLACKHOLE'
+Level Warning
+Code 1286
+Message Unknown storage engine 'ARCHIVE'
+alter table mysql.user drop column default_role, drop column max_statement_time;
+Phase 1/7: Checking and upgrading mysql database
+Processing databases
+mysql
+mysql.column_stats OK
+mysql.columns_priv OK
+mysql.db OK
+mysql.event OK
+mysql.func OK
+mysql.gtid_slave_pos OK
+mysql.help_category OK
+mysql.help_keyword OK
+mysql.help_relation OK
+mysql.help_topic OK
+mysql.host OK
+mysql.index_stats OK
+mysql.innodb_index_stats OK
+mysql.innodb_table_stats OK
+mysql.plugin OK
+mysql.proc OK
+mysql.procs_priv OK
+mysql.proxies_priv OK
+mysql.roles_mapping OK
+mysql.servers OK
+mysql.table_stats OK
+mysql.tables_priv OK
+mysql.time_zone OK
+mysql.time_zone_leap_second OK
+mysql.time_zone_name OK
+mysql.time_zone_transition OK
+mysql.time_zone_transition_type OK
+mysql.user OK
+Upgrading from a version before MariaDB-10.1
+Phase 2/7: Installing used storage engines
+Checking for tables with unknown storage engine
+installing plugin for 'blackhole' storage engine
+installing plugin for 'archive' storage engine
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
+Processing databases
+information_schema
+mtr
+mtr.global_suppressions OK
+mtr.test_suppressions OK
+performance_schema
+test
+test.t1 OK
+test.t2 OK
+Phase 7/7: Running 'FLUSH PRIVILEGES'
+OK
+select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test';
+table_catalog def
+table_schema test
+table_name t1
+table_type BASE TABLE
+engine BLACKHOLE
+row_format Fixed
+table_rows 0
+data_length 0
+table_comment
+table_catalog def
+table_schema test
+table_name t2
+table_type BASE TABLE
+engine ARCHIVE
+row_format Compressed
+table_rows 0
+data_length 521
+table_comment
+drop table t1, t2;
+uninstall plugin blackhole;
+uninstall plugin archive;
diff --git a/mysql-test/r/mysql_upgrade_ssl.result b/mysql-test/r/mysql_upgrade_ssl.result
index e06d1bb1671ad..918a24ffc7130 100644
--- a/mysql-test/r/mysql_upgrade_ssl.result
+++ b/mysql-test/r/mysql_upgrade_ssl.result
@@ -1,7 +1,7 @@
#
# Bug#55672 mysql_upgrade dies with internal error
#
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -32,10 +32,11 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
-Phase 2/6: Fixing views
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names
-Phase 5/6: Checking and upgrading tables
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -43,5 +44,5 @@ mtr.global_suppressions OK
mtr.test_suppressions OK
performance_schema
test
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
diff --git a/mysql-test/r/mysql_upgrade_view.result b/mysql-test/r/mysql_upgrade_view.result
index f43f42f97fd48..dc31592566aac 100644
--- a/mysql-test/r/mysql_upgrade_view.result
+++ b/mysql-test/r/mysql_upgrade_view.result
@@ -63,7 +63,7 @@ test.v2 check error Upgrade required. Please do "REPAIR VIEW `v2`" or dump/reloa
check view v3 for upgrade;
Table Op Msg_type Msg_text
test.v3 check error Upgrade required. Please do "REPAIR VIEW `v3`" or dump/reload to fix it!
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -106,14 +106,15 @@ error : Corrupt
mysql.innodb_table_stats
Error : Unknown storage engine 'InnoDB'
error : Corrupt
-Phase 2/6: Fixing views
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
test.v1 OK
test.v1badcheck OK
test.v2 OK
test.v3 OK
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names
-Phase 5/6: Checking and upgrading tables
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -123,7 +124,7 @@ performance_schema
test
test.kv OK
test.t1 OK
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
show create view v1;
View Create View character_set_client collation_connection
@@ -205,7 +206,7 @@ show create view v4;
View Create View character_set_client collation_connection
v4 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS select `t1`.`a` AS `a` from `t1` latin1 latin1_swedish_ci
MySQL upgrade detected
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -249,14 +250,15 @@ error : Corrupt
mysql.innodb_table_stats
Error : Unknown storage engine 'InnoDB'
error : Corrupt
-Phase 2/6: Fixing views from mysql
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views from mysql
test.v1 OK
test.v2 OK
test.v3 OK
test.v4 OK
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names
-Phase 5/6: Checking and upgrading tables
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
mtr
@@ -266,7 +268,7 @@ performance_schema
test
test.kv OK
test.t1 OK
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
flush tables;
show create view v1;
@@ -323,7 +325,7 @@ rename table mysql.event to mysql.ev_bk;
flush tables;
The --upgrade-system-tables option was used, user tables won't be touched.
MySQL upgrade detected
-Phase 1/6: Checking and upgrading mysql database
+Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
@@ -367,14 +369,15 @@ error : Corrupt
mysql.innodb_table_stats
Error : Unknown storage engine 'InnoDB'
error : Corrupt
-Phase 2/6: Fixing views from mysql
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views from mysql
test.v1 OK
test.v2 OK
test.v3 OK
-Phase 3/6: Running 'mysql_fix_privilege_tables'
-Phase 4/6: Fixing table and database names ... Skipped
-Phase 5/6: Checking and upgrading tables... Skipped
-Phase 6/6: Running 'FLUSH PRIVILEGES'
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names ... Skipped
+Phase 6/7: Checking and upgrading tables... Skipped
+Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
drop table mysql.event;
rename table mysql.ev_bk to mysql.event;
diff --git a/mysql-test/t/mysql_upgrade_noengine.test b/mysql-test/t/mysql_upgrade_noengine.test
new file mode 100644
index 0000000000000..bbc024788b0fb
--- /dev/null
+++ b/mysql-test/t/mysql_upgrade_noengine.test
@@ -0,0 +1,56 @@
+#
+# MDEV-11942 BLACKHOLE is no longer active in 10.1 by default, mysql_upgrade not handling the situation
+#
+source include/have_innodb.inc;
+source include/not_embedded.inc;
+
+if (!$HA_BLACKHOLE_SO) {
+ skip Need blackhole plugin;
+}
+if (!$HA_ARCHIVE_SO) {
+ skip Need Archive plugin;
+}
+
+let $datadir= `select @@datadir`;
+
+install soname 'ha_blackhole';
+install soname 'ha_archive';
+
+vertical_results;
+create table t1 (a int) engine=blackhole;
+create table t2 (a int) engine=archive;
+select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test';
+
+flush tables;
+uninstall plugin blackhole;
+uninstall plugin archive;
+select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test';
+
+# upgrade from 10.1 - engines aren't enabled
+exec $MYSQL_UPGRADE 2>&1;
+select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test';
+
+# pretend it's an upgrade from 10.0
+alter table mysql.user drop column default_role, drop column max_statement_time;
+
+# but mysql_upgrade_info tells otherwise
+remove_file $datadir/mysql_upgrade_info;
+write_file $datadir/mysql_upgrade_info;
+10.1.10-MariaDB
+EOF
+
+# still upgrade from 10.1
+exec $MYSQL_UPGRADE 2>&1;
+select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test';
+
+alter table mysql.user drop column default_role, drop column max_statement_time;
+remove_file $datadir/mysql_upgrade_info;
+
+# upgrade from 10.0 - engines are enabled
+exec $MYSQL_UPGRADE 2>&1;
+select table_catalog, table_schema, table_name, table_type, engine, row_format, table_rows, data_length, table_comment from information_schema.tables where table_schema='test';
+
+drop table t1, t2;
+
+uninstall plugin blackhole;
+uninstall plugin archive;
From 0633d0e2ed606a7fe51d0cbf08c60c5a7d5572f6 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Wed, 8 Mar 2017 14:54:12 +0100
Subject: [PATCH 175/226] don't show 'performance_schema_%_classes_lost'
variables in tests
because FLUSH STATUS does not reset them, so their values
are affected by previously run tests since the last server restart.
---
.../perfschema/include/table_io_result_helper.inc | 3 ++-
mysql-test/suite/perfschema/r/csv_table_io.result | 11 ++---------
mysql-test/suite/perfschema/r/innodb_table_io.result | 11 ++---------
mysql-test/suite/perfschema/r/memory_table_io.result | 11 ++---------
mysql-test/suite/perfschema/r/merge_table_io.result | 11 ++---------
mysql-test/suite/perfschema/r/multi_table_io.result | 11 ++---------
mysql-test/suite/perfschema/r/myisam_table_io.result | 11 ++---------
mysql-test/suite/perfschema/r/part_table_io.result | 11 ++---------
.../suite/perfschema/r/privilege_table_io.result | 11 ++---------
.../suite/perfschema/r/rollback_table_io.result | 11 ++---------
mysql-test/suite/perfschema/r/temp_table_io.result | 11 ++---------
mysql-test/suite/perfschema/r/trigger_table_io.result | 11 ++---------
mysql-test/suite/perfschema/r/view_table_io.result | 11 ++---------
13 files changed, 26 insertions(+), 109 deletions(-)
diff --git a/mysql-test/suite/perfschema/include/table_io_result_helper.inc b/mysql-test/suite/perfschema/include/table_io_result_helper.inc
index 789f7135a1ac0..4732806488e41 100644
--- a/mysql-test/suite/perfschema/include/table_io_result_helper.inc
+++ b/mysql-test/suite/perfschema/include/table_io_result_helper.inc
@@ -14,7 +14,8 @@ eval select event_name,
order by thread_id, event_id;
# In case of failures, this will tell if table io are lost.
-show status like 'performance_schema_%';
+show status where Variable_name like 'performance_schema_%' and
+ Variable_name not like 'performance_schema_%_classes_lost';
# Cleanup
truncate performance_schema.events_waits_history_long;
diff --git a/mysql-test/suite/perfschema/r/csv_table_io.result b/mysql-test/suite/perfschema/r/csv_table_io.result
index f0b5a6bb93501..84b39119dd8ac 100644
--- a/mysql-test/suite/perfschema/r/csv_table_io.result
+++ b/mysql-test/suite/perfschema/r/csv_table_io.result
@@ -111,29 +111,22 @@ wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch NULL
wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
-show status like 'performance_schema_%';
+show status where Variable_name like 'performance_schema_%' and
+Variable_name not like 'performance_schema_%_classes_lost';
Variable_name Value
Performance_schema_accounts_lost 0
-Performance_schema_cond_classes_lost 0
Performance_schema_cond_instances_lost 0
Performance_schema_digest_lost 0
-Performance_schema_file_classes_lost 0
Performance_schema_file_handles_lost 0
Performance_schema_file_instances_lost 0
Performance_schema_hosts_lost 0
Performance_schema_locker_lost 0
-Performance_schema_mutex_classes_lost 0
Performance_schema_mutex_instances_lost 0
-Performance_schema_rwlock_classes_lost 0
Performance_schema_rwlock_instances_lost 0
Performance_schema_session_connect_attrs_lost 0
-Performance_schema_socket_classes_lost 0
Performance_schema_socket_instances_lost 0
-Performance_schema_stage_classes_lost 0
-Performance_schema_statement_classes_lost 0
Performance_schema_table_handles_lost 0
Performance_schema_table_instances_lost 0
-Performance_schema_thread_classes_lost 0
Performance_schema_thread_instances_lost 0
Performance_schema_users_lost 0
truncate performance_schema.events_waits_history_long;
diff --git a/mysql-test/suite/perfschema/r/innodb_table_io.result b/mysql-test/suite/perfschema/r/innodb_table_io.result
index 460518aeb6570..c37c1035e5a30 100644
--- a/mysql-test/suite/perfschema/r/innodb_table_io.result
+++ b/mysql-test/suite/perfschema/r/innodb_table_io.result
@@ -112,29 +112,22 @@ wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch NULL
wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
-show status like 'performance_schema_%';
+show status where Variable_name like 'performance_schema_%' and
+Variable_name not like 'performance_schema_%_classes_lost';
Variable_name Value
Performance_schema_accounts_lost 0
-Performance_schema_cond_classes_lost 0
Performance_schema_cond_instances_lost 0
Performance_schema_digest_lost 0
-Performance_schema_file_classes_lost 0
Performance_schema_file_handles_lost 0
Performance_schema_file_instances_lost 0
Performance_schema_hosts_lost 0
Performance_schema_locker_lost 0
-Performance_schema_mutex_classes_lost 0
Performance_schema_mutex_instances_lost 0
-Performance_schema_rwlock_classes_lost 0
Performance_schema_rwlock_instances_lost 0
Performance_schema_session_connect_attrs_lost 0
-Performance_schema_socket_classes_lost 0
Performance_schema_socket_instances_lost 0
-Performance_schema_stage_classes_lost 0
-Performance_schema_statement_classes_lost 0
Performance_schema_table_handles_lost 0
Performance_schema_table_instances_lost 0
-Performance_schema_thread_classes_lost 0
Performance_schema_thread_instances_lost 0
Performance_schema_users_lost 0
truncate performance_schema.events_waits_history_long;
diff --git a/mysql-test/suite/perfschema/r/memory_table_io.result b/mysql-test/suite/perfschema/r/memory_table_io.result
index 230de71384684..7942015f61876 100644
--- a/mysql-test/suite/perfschema/r/memory_table_io.result
+++ b/mysql-test/suite/perfschema/r/memory_table_io.result
@@ -113,29 +113,22 @@ wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch NULL
wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
-show status like 'performance_schema_%';
+show status where Variable_name like 'performance_schema_%' and
+Variable_name not like 'performance_schema_%_classes_lost';
Variable_name Value
Performance_schema_accounts_lost 0
-Performance_schema_cond_classes_lost 0
Performance_schema_cond_instances_lost 0
Performance_schema_digest_lost 0
-Performance_schema_file_classes_lost 0
Performance_schema_file_handles_lost 0
Performance_schema_file_instances_lost 0
Performance_schema_hosts_lost 0
Performance_schema_locker_lost 0
-Performance_schema_mutex_classes_lost 0
Performance_schema_mutex_instances_lost 0
-Performance_schema_rwlock_classes_lost 0
Performance_schema_rwlock_instances_lost 0
Performance_schema_session_connect_attrs_lost 0
-Performance_schema_socket_classes_lost 0
Performance_schema_socket_instances_lost 0
-Performance_schema_stage_classes_lost 0
-Performance_schema_statement_classes_lost 0
Performance_schema_table_handles_lost 0
Performance_schema_table_instances_lost 0
-Performance_schema_thread_classes_lost 0
Performance_schema_thread_instances_lost 0
Performance_schema_users_lost 0
truncate performance_schema.events_waits_history_long;
diff --git a/mysql-test/suite/perfschema/r/merge_table_io.result b/mysql-test/suite/perfschema/r/merge_table_io.result
index 7f0b602778c7b..d390ba67b5f57 100644
--- a/mysql-test/suite/perfschema/r/merge_table_io.result
+++ b/mysql-test/suite/perfschema/r/merge_table_io.result
@@ -143,29 +143,22 @@ wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
-show status like 'performance_schema_%';
+show status where Variable_name like 'performance_schema_%' and
+Variable_name not like 'performance_schema_%_classes_lost';
Variable_name Value
Performance_schema_accounts_lost 0
-Performance_schema_cond_classes_lost 0
Performance_schema_cond_instances_lost 0
Performance_schema_digest_lost 0
-Performance_schema_file_classes_lost 0
Performance_schema_file_handles_lost 0
Performance_schema_file_instances_lost 0
Performance_schema_hosts_lost 0
Performance_schema_locker_lost 0
-Performance_schema_mutex_classes_lost 0
Performance_schema_mutex_instances_lost 0
-Performance_schema_rwlock_classes_lost 0
Performance_schema_rwlock_instances_lost 0
Performance_schema_session_connect_attrs_lost 0
-Performance_schema_socket_classes_lost 0
Performance_schema_socket_instances_lost 0
-Performance_schema_stage_classes_lost 0
-Performance_schema_statement_classes_lost 0
Performance_schema_table_handles_lost 0
Performance_schema_table_instances_lost 0
-Performance_schema_thread_classes_lost 0
Performance_schema_thread_instances_lost 0
Performance_schema_users_lost 0
truncate performance_schema.events_waits_history_long;
diff --git a/mysql-test/suite/perfschema/r/multi_table_io.result b/mysql-test/suite/perfschema/r/multi_table_io.result
index 74c8b94c1d5e3..929e1791c6180 100644
--- a/mysql-test/suite/perfschema/r/multi_table_io.result
+++ b/mysql-test/suite/perfschema/r/multi_table_io.result
@@ -72,29 +72,22 @@ wait/io/table/sql/handler handler.cc: TABLE test1 t2 fetch NULL
wait/io/table/sql/handler handler.cc: TABLE test t1 delete NULL
wait/io/table/sql/handler handler.cc: TABLE test1 t2 fetch NULL
wait/io/table/sql/handler handler.cc: TABLE test1 t2 delete NULL
-show status like 'performance_schema_%';
+show status where Variable_name like 'performance_schema_%' and
+Variable_name not like 'performance_schema_%_classes_lost';
Variable_name Value
Performance_schema_accounts_lost 0
-Performance_schema_cond_classes_lost 0
Performance_schema_cond_instances_lost 0
Performance_schema_digest_lost 0
-Performance_schema_file_classes_lost 0
Performance_schema_file_handles_lost 0
Performance_schema_file_instances_lost 0
Performance_schema_hosts_lost 0
Performance_schema_locker_lost 0
-Performance_schema_mutex_classes_lost 0
Performance_schema_mutex_instances_lost 0
-Performance_schema_rwlock_classes_lost 0
Performance_schema_rwlock_instances_lost 0
Performance_schema_session_connect_attrs_lost 0
-Performance_schema_socket_classes_lost 0
Performance_schema_socket_instances_lost 0
-Performance_schema_stage_classes_lost 0
-Performance_schema_statement_classes_lost 0
Performance_schema_table_handles_lost 0
Performance_schema_table_instances_lost 0
-Performance_schema_thread_classes_lost 0
Performance_schema_thread_instances_lost 0
Performance_schema_users_lost 0
truncate performance_schema.events_waits_history_long;
diff --git a/mysql-test/suite/perfschema/r/myisam_table_io.result b/mysql-test/suite/perfschema/r/myisam_table_io.result
index 432e59648028d..97a099581d47d 100644
--- a/mysql-test/suite/perfschema/r/myisam_table_io.result
+++ b/mysql-test/suite/perfschema/r/myisam_table_io.result
@@ -111,29 +111,22 @@ wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch NULL
wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
-show status like 'performance_schema_%';
+show status where Variable_name like 'performance_schema_%' and
+Variable_name not like 'performance_schema_%_classes_lost';
Variable_name Value
Performance_schema_accounts_lost 0
-Performance_schema_cond_classes_lost 0
Performance_schema_cond_instances_lost 0
Performance_schema_digest_lost 0
-Performance_schema_file_classes_lost 0
Performance_schema_file_handles_lost 0
Performance_schema_file_instances_lost 0
Performance_schema_hosts_lost 0
Performance_schema_locker_lost 0
-Performance_schema_mutex_classes_lost 0
Performance_schema_mutex_instances_lost 0
-Performance_schema_rwlock_classes_lost 0
Performance_schema_rwlock_instances_lost 0
Performance_schema_session_connect_attrs_lost 0
-Performance_schema_socket_classes_lost 0
Performance_schema_socket_instances_lost 0
-Performance_schema_stage_classes_lost 0
-Performance_schema_statement_classes_lost 0
Performance_schema_table_handles_lost 0
Performance_schema_table_instances_lost 0
-Performance_schema_thread_classes_lost 0
Performance_schema_thread_instances_lost 0
Performance_schema_users_lost 0
truncate performance_schema.events_waits_history_long;
diff --git a/mysql-test/suite/perfschema/r/part_table_io.result b/mysql-test/suite/perfschema/r/part_table_io.result
index 2aa12851679a2..c71767bc24f69 100644
--- a/mysql-test/suite/perfschema/r/part_table_io.result
+++ b/mysql-test/suite/perfschema/r/part_table_io.result
@@ -113,29 +113,22 @@ wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch NULL
wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
-show status like 'performance_schema_%';
+show status where Variable_name like 'performance_schema_%' and
+Variable_name not like 'performance_schema_%_classes_lost';
Variable_name Value
Performance_schema_accounts_lost 0
-Performance_schema_cond_classes_lost 0
Performance_schema_cond_instances_lost 0
Performance_schema_digest_lost 0
-Performance_schema_file_classes_lost 0
Performance_schema_file_handles_lost 0
Performance_schema_file_instances_lost 0
Performance_schema_hosts_lost 0
Performance_schema_locker_lost 0
-Performance_schema_mutex_classes_lost 0
Performance_schema_mutex_instances_lost 0
-Performance_schema_rwlock_classes_lost 0
Performance_schema_rwlock_instances_lost 0
Performance_schema_session_connect_attrs_lost 0
-Performance_schema_socket_classes_lost 0
Performance_schema_socket_instances_lost 0
-Performance_schema_stage_classes_lost 0
-Performance_schema_statement_classes_lost 0
Performance_schema_table_handles_lost 0
Performance_schema_table_instances_lost 0
-Performance_schema_thread_classes_lost 0
Performance_schema_thread_instances_lost 0
Performance_schema_users_lost 0
truncate performance_schema.events_waits_history_long;
diff --git a/mysql-test/suite/perfschema/r/privilege_table_io.result b/mysql-test/suite/perfschema/r/privilege_table_io.result
index f1f0946cb901d..4885086f77624 100644
--- a/mysql-test/suite/perfschema/r/privilege_table_io.result
+++ b/mysql-test/suite/perfschema/r/privilege_table_io.result
@@ -113,29 +113,22 @@ wait/io/table/sql/handler handler.cc: TABLE mysql servers fetch NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
-show status like 'performance_schema_%';
+show status where Variable_name like 'performance_schema_%' and
+Variable_name not like 'performance_schema_%_classes_lost';
Variable_name Value
Performance_schema_accounts_lost 0
-Performance_schema_cond_classes_lost 0
Performance_schema_cond_instances_lost 0
Performance_schema_digest_lost 0
-Performance_schema_file_classes_lost 0
Performance_schema_file_handles_lost 0
Performance_schema_file_instances_lost 0
Performance_schema_hosts_lost 0
Performance_schema_locker_lost 0
-Performance_schema_mutex_classes_lost 0
Performance_schema_mutex_instances_lost 0
-Performance_schema_rwlock_classes_lost 0
Performance_schema_rwlock_instances_lost 0
Performance_schema_session_connect_attrs_lost 0
-Performance_schema_socket_classes_lost 0
Performance_schema_socket_instances_lost 0
-Performance_schema_stage_classes_lost 0
-Performance_schema_statement_classes_lost 0
Performance_schema_table_handles_lost 0
Performance_schema_table_instances_lost 0
-Performance_schema_thread_classes_lost 0
Performance_schema_thread_instances_lost 0
Performance_schema_users_lost 0
truncate performance_schema.events_waits_history_long;
diff --git a/mysql-test/suite/perfschema/r/rollback_table_io.result b/mysql-test/suite/perfschema/r/rollback_table_io.result
index f08d11e21d825..a9cc5b1da398b 100644
--- a/mysql-test/suite/perfschema/r/rollback_table_io.result
+++ b/mysql-test/suite/perfschema/r/rollback_table_io.result
@@ -54,29 +54,22 @@ wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test t1 insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
-show status like 'performance_schema_%';
+show status where Variable_name like 'performance_schema_%' and
+Variable_name not like 'performance_schema_%_classes_lost';
Variable_name Value
Performance_schema_accounts_lost 0
-Performance_schema_cond_classes_lost 0
Performance_schema_cond_instances_lost 0
Performance_schema_digest_lost 0
-Performance_schema_file_classes_lost 0
Performance_schema_file_handles_lost 0
Performance_schema_file_instances_lost 0
Performance_schema_hosts_lost 0
Performance_schema_locker_lost 0
-Performance_schema_mutex_classes_lost 0
Performance_schema_mutex_instances_lost 0
-Performance_schema_rwlock_classes_lost 0
Performance_schema_rwlock_instances_lost 0
Performance_schema_session_connect_attrs_lost 0
-Performance_schema_socket_classes_lost 0
Performance_schema_socket_instances_lost 0
-Performance_schema_stage_classes_lost 0
-Performance_schema_statement_classes_lost 0
Performance_schema_table_handles_lost 0
Performance_schema_table_instances_lost 0
-Performance_schema_thread_classes_lost 0
Performance_schema_thread_instances_lost 0
Performance_schema_users_lost 0
truncate performance_schema.events_waits_history_long;
diff --git a/mysql-test/suite/perfschema/r/temp_table_io.result b/mysql-test/suite/perfschema/r/temp_table_io.result
index c5de365dbf454..0e1bf01ef9a0a 100644
--- a/mysql-test/suite/perfschema/r/temp_table_io.result
+++ b/mysql-test/suite/perfschema/r/temp_table_io.result
@@ -84,29 +84,22 @@ wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
-show status like 'performance_schema_%';
+show status where Variable_name like 'performance_schema_%' and
+Variable_name not like 'performance_schema_%_classes_lost';
Variable_name Value
Performance_schema_accounts_lost 0
-Performance_schema_cond_classes_lost 0
Performance_schema_cond_instances_lost 0
Performance_schema_digest_lost 0
-Performance_schema_file_classes_lost 0
Performance_schema_file_handles_lost 0
Performance_schema_file_instances_lost 0
Performance_schema_hosts_lost 0
Performance_schema_locker_lost 0
-Performance_schema_mutex_classes_lost 0
Performance_schema_mutex_instances_lost 0
-Performance_schema_rwlock_classes_lost 0
Performance_schema_rwlock_instances_lost 0
Performance_schema_session_connect_attrs_lost 0
-Performance_schema_socket_classes_lost 0
Performance_schema_socket_instances_lost 0
-Performance_schema_stage_classes_lost 0
-Performance_schema_statement_classes_lost 0
Performance_schema_table_handles_lost 0
Performance_schema_table_instances_lost 0
-Performance_schema_thread_classes_lost 0
Performance_schema_thread_instances_lost 0
Performance_schema_users_lost 0
truncate performance_schema.events_waits_history_long;
diff --git a/mysql-test/suite/perfschema/r/trigger_table_io.result b/mysql-test/suite/perfschema/r/trigger_table_io.result
index e77e7d864f1c9..9fc63e6967590 100644
--- a/mysql-test/suite/perfschema/r/trigger_table_io.result
+++ b/mysql-test/suite/perfschema/r/trigger_table_io.result
@@ -169,29 +169,22 @@ wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test t2 fetch NULL
wait/io/table/sql/handler handler.cc: TABLE test t2 fetch NULL
wait/io/table/sql/handler handler.cc: TABLE test t2 fetch NULL
-show status like 'performance_schema_%';
+show status where Variable_name like 'performance_schema_%' and
+Variable_name not like 'performance_schema_%_classes_lost';
Variable_name Value
Performance_schema_accounts_lost 0
-Performance_schema_cond_classes_lost 0
Performance_schema_cond_instances_lost 0
Performance_schema_digest_lost 0
-Performance_schema_file_classes_lost 0
Performance_schema_file_handles_lost 0
Performance_schema_file_instances_lost 0
Performance_schema_hosts_lost 0
Performance_schema_locker_lost 0
-Performance_schema_mutex_classes_lost 0
Performance_schema_mutex_instances_lost 0
-Performance_schema_rwlock_classes_lost 0
Performance_schema_rwlock_instances_lost 0
Performance_schema_session_connect_attrs_lost 0
-Performance_schema_socket_classes_lost 0
Performance_schema_socket_instances_lost 0
-Performance_schema_stage_classes_lost 0
-Performance_schema_statement_classes_lost 0
Performance_schema_table_handles_lost 0
Performance_schema_table_instances_lost 0
-Performance_schema_thread_classes_lost 0
Performance_schema_thread_instances_lost 0
Performance_schema_users_lost 0
truncate performance_schema.events_waits_history_long;
diff --git a/mysql-test/suite/perfschema/r/view_table_io.result b/mysql-test/suite/perfschema/r/view_table_io.result
index db6acf65c73c1..5d8ad26ae7736 100644
--- a/mysql-test/suite/perfschema/r/view_table_io.result
+++ b/mysql-test/suite/perfschema/r/view_table_io.result
@@ -120,29 +120,22 @@ wait/io/table/sql/handler handler.cc: TABLE test no_index_tab fetch NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
wait/io/table/sql/handler handler.cc: TABLE test marker insert NULL
-show status like 'performance_schema_%';
+show status where Variable_name like 'performance_schema_%' and
+Variable_name not like 'performance_schema_%_classes_lost';
Variable_name Value
Performance_schema_accounts_lost 0
-Performance_schema_cond_classes_lost 0
Performance_schema_cond_instances_lost 0
Performance_schema_digest_lost 0
-Performance_schema_file_classes_lost 0
Performance_schema_file_handles_lost 0
Performance_schema_file_instances_lost 0
Performance_schema_hosts_lost 0
Performance_schema_locker_lost 0
-Performance_schema_mutex_classes_lost 0
Performance_schema_mutex_instances_lost 0
-Performance_schema_rwlock_classes_lost 0
Performance_schema_rwlock_instances_lost 0
Performance_schema_session_connect_attrs_lost 0
-Performance_schema_socket_classes_lost 0
Performance_schema_socket_instances_lost 0
-Performance_schema_stage_classes_lost 0
-Performance_schema_statement_classes_lost 0
Performance_schema_table_handles_lost 0
Performance_schema_table_instances_lost 0
-Performance_schema_thread_classes_lost 0
Performance_schema_thread_instances_lost 0
Performance_schema_users_lost 0
truncate performance_schema.events_waits_history_long;
From aa51b559abec01eca9f5a7628e4fe0a106ee8e52 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Mon, 6 Mar 2017 15:07:46 +0100
Subject: [PATCH 176/226] typo fixed
---
storage/maria/maria_def.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h
index 154d60a616474..7c444532b61a5 100644
--- a/storage/maria/maria_def.h
+++ b/storage/maria/maria_def.h
@@ -889,7 +889,7 @@ struct st_maria_handler
#define PACK_TYPE_SELECTED 1 /* Bits in field->pack_type */
#define PACK_TYPE_SPACE_FIELDS 2
#define PACK_TYPE_ZERO_FILL 4
-#define MARIA_FOUND_WRONG_KEY 32738 /* Impossible value from ha_key_cmp */
+#define MARIA_FOUND_WRONG_KEY 32768 /* Impossible value from ha_key_cmp */
#define MARIA_BLOCK_SIZE(key_length,data_pointer,key_pointer,block_size) (((((key_length)+(data_pointer)+(key_pointer))*4+(key_pointer)+2)/(block_size)+1)*(block_size))
#define MARIA_MAX_KEYPTR_SIZE 5 /* For calculating block lengths */
From 2b1bbac5fa881b8e135dbad3e0ff6b9e2763e24d Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Sun, 5 Mar 2017 20:51:31 +0100
Subject: [PATCH 177/226] cleanup: remove a duplicate file
---
mysys_ssl/CMakeLists.txt | 1 -
mysys_ssl/my_rnd.cc | 103 ---------------------------------------
2 files changed, 104 deletions(-)
delete mode 100644 mysys_ssl/my_rnd.cc
diff --git a/mysys_ssl/CMakeLists.txt b/mysys_ssl/CMakeLists.txt
index 8a8f81d70ae2a..b00213bc49287 100644
--- a/mysys_ssl/CMakeLists.txt
+++ b/mysys_ssl/CMakeLists.txt
@@ -36,7 +36,6 @@ SET(MYSYS_SSL_SOURCES
my_sha1.cc
my_sha2.cc
my_md5.cc
- my_rnd.cc
my_crypt.cc
)
diff --git a/mysys_ssl/my_rnd.cc b/mysys_ssl/my_rnd.cc
deleted file mode 100644
index aa8fb63cd4d9d..0000000000000
--- a/mysys_ssl/my_rnd.cc
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- Copyright (c) 2012, 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, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
-
-#include
-#include
-#include
-
-#if defined(HAVE_YASSL)
-#if defined(YASSL_PREFIX)
-#define RAND_bytes yaRAND_bytes
-#endif /* YASSL_PREFIX */
-
-#include
-
-#elif defined(HAVE_OPENSSL)
-#include
-#endif /* HAVE_YASSL */
-
-
-/*
- A wrapper to use OpenSSL/yaSSL PRNGs.
-*/
-
-extern "C" {
-
-/*
- Initialize random generator
-
- NOTES
- MySQL's password checks depends on this, so don't do any changes
- that changes the random numbers that are generated!
-*/
-
-void my_rnd_init(struct my_rnd_struct *rand_st, ulong seed1, ulong seed2)
-{
-#ifdef HAVE_valgrind
- bzero((char*) rand_st,sizeof(*rand_st)); /* Avoid UMC varnings */
-#endif
- rand_st->max_value= 0x3FFFFFFFL;
- rand_st->max_value_dbl=(double) rand_st->max_value;
- rand_st->seed1=seed1%rand_st->max_value ;
- rand_st->seed2=seed2%rand_st->max_value;
-}
-
-/**
- Generate random number.
-
- @param rand_st [INOUT] Structure used for number generation.
-
- @retval Generated pseudo random number.
-*/
-
-double my_rnd(struct my_rnd_struct *rand_st)
-{
- rand_st->seed1= (rand_st->seed1*3+rand_st->seed2) % rand_st->max_value;
- rand_st->seed2= (rand_st->seed1+rand_st->seed2+33) % rand_st->max_value;
- return (((double) rand_st->seed1) / rand_st->max_value_dbl);
-}
-
-/**
- Generate a random number using the OpenSSL/yaSSL supplied
- random number generator if available.
-
- @param rand_st [INOUT] Structure used for number generation
- only if none of the SSL libraries are
- available.
-
- @retval Generated random number.
-*/
-
-double my_rnd_ssl(struct my_rnd_struct *rand_st)
-{
-
-#if defined(HAVE_YASSL) || defined(HAVE_OPENSSL)
- int rc;
- unsigned int res;
-
-#if defined(HAVE_YASSL)
- rc= yaSSL::RAND_bytes((unsigned char *) &res, sizeof (unsigned int));
-#else
- rc= RAND_bytes((unsigned char *) &res, sizeof (unsigned int));
-#endif /* HAVE_YASSL */
- if (rc)
- return (double)res / (double)UINT_MAX;
-
-#endif /* defined(HAVE_YASSL) || defined(HAVE_OPENSSL) */
- return my_rnd(rand_st);
-}
-
-}
From 6cddd12ad6eeea82b1087574e5dd5cb9accd7641 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Sun, 5 Mar 2017 15:50:32 +0100
Subject: [PATCH 178/226] make sql_udf.cc to shorten dlerror() messages
just as sql_plugin.cc does
---
include/my_sys.h | 2 ++
mysys/CMakeLists.txt | 2 +-
mysys/my_dlerror.c | 31 +++++++++++++++++++++++++++++++
sql/sql_plugin.cc | 12 ++----------
sql/sql_udf.cc | 9 ++++-----
5 files changed, 40 insertions(+), 16 deletions(-)
create mode 100644 mysys/my_dlerror.c
diff --git a/include/my_sys.h b/include/my_sys.h
index d30c3ee78d381..6d4faeb5c6aa5 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -998,6 +998,8 @@ void my_uuid(uchar *guid);
void my_uuid2str(const uchar *guid, char *s);
void my_uuid_end(void);
+const char *my_dlerror(const char *dlpath);
+
/* character sets */
extern void my_charset_loader_init_mysys(MY_CHARSET_LOADER *loader);
extern uint get_charset_number(const char *cs_name, uint cs_flags);
diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
index 3cd243f9f141f..eb7f75ed6a8ff 100644
--- a/mysys/CMakeLists.txt
+++ b/mysys/CMakeLists.txt
@@ -41,7 +41,7 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c my_default.c
my_atomic.c my_getncpus.c my_safehash.c my_chmod.c my_rnd.c
my_uuid.c wqueue.c waiting_threads.c ma_dyncol.c
my_rdtsc.c my_context.c psi_noop.c
- file_logger.c)
+ file_logger.c my_dlerror.c)
IF (WIN32)
SET (MYSYS_SOURCES ${MYSYS_SOURCES} my_winthread.c my_wincond.c my_winerr.c my_winfile.c my_windac.c my_conio.c)
diff --git a/mysys/my_dlerror.c b/mysys/my_dlerror.c
new file mode 100644
index 0000000000000..db21b7fc274e6
--- /dev/null
+++ b/mysys/my_dlerror.c
@@ -0,0 +1,31 @@
+/*
+ Copyright (c) 2017, 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-1301 USA */
+
+#include
+#include
+
+const char *my_dlerror(const char *dlpath)
+{
+ const char *errmsg=dlerror();
+ size_t dlpathlen= strlen(dlpath);
+ if (!strncmp(dlpath, errmsg, dlpathlen))
+ { /* if errmsg starts from dlpath, trim this prefix */
+ errmsg+=dlpathlen;
+ if (*errmsg == ':') errmsg++;
+ if (*errmsg == ' ') errmsg++;
+ }
+ return errmsg;
+}
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 4ba9b82cf47d5..14c9071a283bf 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -723,7 +723,7 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)
{
#ifdef HAVE_DLOPEN
char dlpath[FN_REFLEN];
- uint plugin_dir_len, dummy_errors, dlpathlen, i;
+ uint plugin_dir_len, dummy_errors, i;
struct st_plugin_dl *tmp= 0, plugin_dl;
void *sym;
st_ptr_backup tmp_backup[array_elements(list_of_services)];
@@ -759,15 +759,7 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)
/* Open new dll handle */
if (!(plugin_dl.handle= dlopen(dlpath, RTLD_NOW)))
{
- const char *errmsg=dlerror();
- dlpathlen= strlen(dlpath);
- if (!strncmp(dlpath, errmsg, dlpathlen))
- { // if errmsg starts from dlpath, trim this prefix.
- errmsg+=dlpathlen;
- if (*errmsg == ':') errmsg++;
- if (*errmsg == ' ') errmsg++;
- }
- report_error(report, ER_CANT_OPEN_LIBRARY, dlpath, errno, errmsg);
+ report_error(report, ER_CANT_OPEN_LIBRARY, dlpath, errno, my_dlerror(dlpath));
goto ret;
}
dlopen_count++;
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index aa4859b663931..4ccd4948b58d3 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -227,14 +227,13 @@ void udf_init()
if (dl == NULL)
{
char dlpath[FN_REFLEN];
- strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", tmp->dl,
- NullS);
+ strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", tmp->dl, NullS);
(void) unpack_filename(dlpath, dlpath);
if (!(dl= dlopen(dlpath, RTLD_NOW)))
{
/* Print warning to log */
sql_print_error(ER_THD(new_thd, ER_CANT_OPEN_LIBRARY),
- tmp->dl, errno, dlerror());
+ tmp->dl, errno, my_dlerror(dlpath));
/* Keep the udf in the hash so that we can remove it later */
continue;
}
@@ -538,10 +537,10 @@ int mysql_create_function(THD *thd,udf_func *udf)
if (!(dl = dlopen(dlpath, RTLD_NOW)))
{
+ my_error(ER_CANT_OPEN_LIBRARY, MYF(0),
+ udf->dl, errno, my_dlerror(dlpath));
DBUG_PRINT("error",("dlopen of %s failed, error: %d (%s)",
udf->dl, errno, dlerror()));
- my_error(ER_CANT_OPEN_LIBRARY, MYF(0),
- udf->dl, errno, dlerror());
goto err;
}
new_dl=1;
From bd1139ad2722cf8717cd1aaac4431f369d39562f Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Mon, 6 Mar 2017 12:45:36 +0100
Subject: [PATCH 179/226] cleanup: generalize my_sha1.cc
move most of the code into my_sha.ic, making it independent
from the actual SHAx variant.
---
include/sha1.h | 25 ------
mysys_ssl/my_sha.ic | 186 +++++++++++++++++++++++++++++++++++++++
mysys_ssl/my_sha1.cc | 136 +---------------------------
plugin/feedback/utils.cc | 5 +-
sql/item_strfunc.cc | 13 ++-
sql/password.c | 45 +++++-----
6 files changed, 219 insertions(+), 191 deletions(-)
delete mode 100644 include/sha1.h
create mode 100644 mysys_ssl/my_sha.ic
diff --git a/include/sha1.h b/include/sha1.h
deleted file mode 100644
index d927cd26ad9b1..0000000000000
--- a/include/sha1.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef SHA1_INCLUDED
-#define SHA1_INCLUDED
-
-/* Copyright (c) 2013, Monty Program 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 Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-#include
-#define SHA1_HASH_SIZE MY_SHA1_HASH_SIZE
-#define compute_sha1_hash(A,B,C) my_sha1(A,B,C)
-#define compute_sha1_hash_multi(A,B,C,D,E) my_sha1_multi(A,B,C,D,E,NULL)
-
-#endif /* SHA__INCLUDED */
diff --git a/mysys_ssl/my_sha.ic b/mysys_ssl/my_sha.ic
new file mode 100644
index 0000000000000..5a95c9c468227
--- /dev/null
+++ b/mysys_ssl/my_sha.ic
@@ -0,0 +1,186 @@
+/* Copyright (c) 2012, Oracle and/or its affiliates.
+ Copyright (c) 2014, 2017, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+
+/**
+ @file
+
+ @brief
+ Wrapper functions for OpenSSL, YaSSL implementations. Also provides a
+ Compatibility layer to make available YaSSL's SHAn implementation.
+*/
+
+#include
+#include
+
+#define HASH_SIZE 20
+
+#if defined(HAVE_YASSL)
+#include "sha.hpp"
+
+#define xCONTEXT(x) TaoCrypt::SHA ## x
+#define yCONTEXT(y) xCONTEXT(y)
+#define CONTEXT yCONTEXT(NUM)
+#define SHA1 SHA
+
+static void sha_init(CONTEXT *context)
+{
+ context->Init();
+}
+
+/*
+ this is a variant of sha_init to be used in this file only.
+ does nothing for yassl, because the context's constructor was called automatically.
+*/
+static void sha_init_fast(CONTEXT *context)
+{
+}
+
+static void sha_input(CONTEXT *context, const uchar *buf, unsigned len)
+{
+ context->Update((const TaoCrypt::byte *) buf, len);
+}
+
+static void sha_result(CONTEXT *context, uchar digest[HASH_SIZE])
+{
+ context->Final((TaoCrypt::byte *) digest);
+}
+
+#elif defined(HAVE_OPENSSL)
+#include
+
+#define xCONTEXT(x) SHA ## x ## _CTX
+#define yCONTEXT(y) xCONTEXT(y)
+#define CONTEXT yCONTEXT(NUM)
+#define SHA1_CTX SHA_CTX
+
+#define xSHA_Init(x) SHA ## x ## _Init
+#define xSHA_Update(x) SHA ## x ## _Update
+#define xSHA_Final(x) SHA ## x ## _Final
+#define ySHA_Init(y) xSHA_Init(y)
+#define ySHA_Update(y) xSHA_Update(y)
+#define ySHA_Final(y) xSHA_Final(y)
+#define SHA_Init ySHA_Init(NUM)
+#define SHA_Update ySHA_Update(NUM)
+#define SHA_Final ySHA_Final(NUM)
+
+static void sha_init(CONTEXT *context)
+{
+ SHA_Init(context);
+}
+
+static void sha_init_fast(CONTEXT *context)
+{
+ sha_init(context);
+}
+
+static void sha_input(CONTEXT *context, const uchar *buf, unsigned len)
+{
+ SHA_Update(context, buf, len);
+}
+
+static void sha_result(CONTEXT *context, uchar digest[HASH_SIZE])
+{
+ SHA_Final(digest, context);
+}
+
+#endif /* HAVE_YASSL */
+
+#define xmy_sha_multi(x) my_sha ## x ## _multi
+#define xmy_sha_context_size(x) my_sha ## x ## _context_size
+#define xmy_sha_init(x) my_sha ## x ## _init
+#define xmy_sha_input(x) my_sha ## x ## _input
+#define xmy_sha_result(x) my_sha ## x ## _result
+#define xmy_sha(x) my_sha ## x
+#define ymy_sha_multi(y) xmy_sha_multi(y)
+#define ymy_sha_context_size(y) xmy_sha_context_size(y)
+#define ymy_sha_init(y) xmy_sha_init(y)
+#define ymy_sha_input(y) xmy_sha_input(y)
+#define ymy_sha_result(y) xmy_sha_result(y)
+#define ymy_sha(y) xmy_sha(y)
+#define my_sha_multi ymy_sha_multi(NUM)
+#define my_sha_context_size ymy_sha_context_size(NUM)
+#define my_sha_init ymy_sha_init(NUM)
+#define my_sha_input ymy_sha_input(NUM)
+#define my_sha_result ymy_sha_result(NUM)
+#define my_sha ymy_sha(NUM)
+
+/**
+ Wrapper function to compute SHAn message digest.
+
+ @param digest [out] Computed SHAn digest
+ @param buf [in] Message to be computed
+ @param len [in] Length of the message
+
+ @return void
+*/
+void my_sha(uchar *digest, const char *buf, size_t len)
+{
+ CONTEXT context;
+
+ sha_init_fast(&context);
+ sha_input(&context, (const uchar *)buf, len);
+ sha_result(&context, digest);
+}
+
+
+/**
+ Wrapper function to compute SHAn message digest for
+ two messages in order to emulate shaN(msg1, msg2).
+
+ @param digest [out] Computed SHAn digest
+ @param buf1 [in] First message
+ @param len1 [in] Length of first message
+ @param buf2 [in] Second message
+ @param len2 [in] Length of second message
+
+ @return void
+*/
+void my_sha_multi(uchar *digest, ...)
+{
+ va_list args;
+ va_start(args, digest);
+
+ CONTEXT context;
+ const uchar *str;
+
+ sha_init_fast(&context);
+ for (str= va_arg(args, const uchar*); str; str= va_arg(args, const uchar*))
+ sha_input(&context, str, va_arg(args, size_t));
+
+ sha_result(&context, digest);
+ va_end(args);
+}
+
+size_t my_sha_context_size()
+{
+ return sizeof(CONTEXT);
+}
+
+void my_sha_init(void *context)
+{
+ sha_init((CONTEXT *)context);
+}
+
+void my_sha_input(void *context, const uchar *buf, size_t len)
+{
+ sha_input((CONTEXT *)context, buf, len);
+}
+
+void my_sha_result(void *context, uchar *digest)
+{
+ sha_result((CONTEXT *)context, digest);
+}
diff --git a/mysys_ssl/my_sha1.cc b/mysys_ssl/my_sha1.cc
index 9b12d1f1ae8c5..dc6a7a4617904 100644
--- a/mysys_ssl/my_sha1.cc
+++ b/mysys_ssl/my_sha1.cc
@@ -1,5 +1,4 @@
-/* Copyright (c) 2012, Oracle and/or its affiliates.
- Copyright (c) 2014, SkySQL Ab.
+/* Copyright (c) 2017, 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
@@ -14,135 +13,6 @@
along with this program; if not, write to the Free Software Foundation,
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+#define NUM 1
-/**
- @file
-
- @brief
- Wrapper functions for OpenSSL, YaSSL implementations. Also provides a
- Compatibility layer to make available YaSSL's SHA1 implementation.
-*/
-
-#include
-#include
-#include
-
-#if defined(HAVE_YASSL)
-#include "sha.hpp"
-
-typedef TaoCrypt::SHA SHA_CTX;
-
-static void sha1_init(SHA_CTX *context)
-{
- context->Init();
-}
-
-/*
- this is a variant of sha1_init to be used in this file only.
- does nothing for yassl, because the context's constructor was called automatically.
-*/
-static void sha1_init_fast(SHA_CTX *context)
-{
-}
-
-static void sha1_input(SHA_CTX *context, const uchar *buf, unsigned len)
-{
- context->Update((const TaoCrypt::byte *) buf, len);
-}
-
-static void sha1_result(SHA_CTX *context, uchar digest[SHA1_HASH_SIZE])
-{
- context->Final((TaoCrypt::byte *) digest);
-}
-
-#elif defined(HAVE_OPENSSL)
-#include
-
-static void sha1_init(SHA_CTX *context)
-{
- SHA1_Init(context);
-}
-
-static void sha1_init_fast(SHA_CTX *context)
-{
- sha1_init(context);
-}
-
-static void sha1_input(SHA_CTX *context, const uchar *buf, unsigned len)
-{
- SHA1_Update(context, buf, len);
-}
-
-static void sha1_result(SHA_CTX *context, uchar digest[SHA1_HASH_SIZE])
-{
- SHA1_Final(digest, context);
-}
-
-#endif /* HAVE_YASSL */
-
-/**
- Wrapper function to compute SHA1 message digest.
-
- @param digest [out] Computed SHA1 digest
- @param buf [in] Message to be computed
- @param len [in] Length of the message
-
- @return void
-*/
-void my_sha1(uchar *digest, const char *buf, size_t len)
-{
- SHA_CTX sha1_context;
-
- sha1_init_fast(&sha1_context);
- sha1_input(&sha1_context, (const uchar *)buf, len);
- sha1_result(&sha1_context, digest);
-}
-
-
-/**
- Wrapper function to compute SHA1 message digest for
- two messages in order to emulate sha1(msg1, msg2).
-
- @param digest [out] Computed SHA1 digest
- @param buf1 [in] First message
- @param len1 [in] Length of first message
- @param buf2 [in] Second message
- @param len2 [in] Length of second message
-
- @return void
-*/
-void my_sha1_multi(uchar *digest, ...)
-{
- va_list args;
- va_start(args, digest);
-
- SHA_CTX sha1_context;
- const uchar *str;
-
- sha1_init_fast(&sha1_context);
- for (str= va_arg(args, const uchar*); str; str= va_arg(args, const uchar*))
- sha1_input(&sha1_context, str, va_arg(args, size_t));
-
- sha1_result(&sha1_context, digest);
- va_end(args);
-}
-
-size_t my_sha1_context_size()
-{
- return sizeof(SHA_CTX);
-}
-
-void my_sha1_init(void *context)
-{
- sha1_init((SHA_CTX *)context);
-}
-
-void my_sha1_input(void *context, const uchar *buf, size_t len)
-{
- sha1_input((SHA_CTX *)context, buf, len);
-}
-
-void my_sha1_result(void *context, uchar *digest)
-{
- sha1_result((SHA_CTX *)context, digest);
-}
+#include "my_sha.ic"
diff --git a/plugin/feedback/utils.cc b/plugin/feedback/utils.cc
index dad3d59e76dcc..669ed9a442711 100644
--- a/plugin/feedback/utils.cc
+++ b/plugin/feedback/utils.cc
@@ -20,7 +20,6 @@
#endif
#include
-#include
#if defined (_WIN32)
#define HAVE_SYS_UTSNAME_H
@@ -420,7 +419,7 @@ int fill_collation_statistics(THD *thd, TABLE_LIST *tables)
int calculate_server_uid(char *dest)
{
uchar rawbuf[2 + 6];
- uchar shabuf[SHA1_HASH_SIZE];
+ uchar shabuf[MY_SHA1_HASH_SIZE];
int2store(rawbuf, mysqld_port);
if (my_gethwaddr(rawbuf + 2))
@@ -429,7 +428,7 @@ int calculate_server_uid(char *dest)
return 1;
}
- compute_sha1_hash((uint8*) shabuf, (char*) rawbuf, sizeof(rawbuf));
+ my_sha1((uint8*) shabuf, (char*) rawbuf, sizeof(rawbuf));
assert(base64_needed_encoded_length(sizeof(shabuf)) <= SERVER_UID_SIZE);
base64_encode(shabuf, sizeof(shabuf), dest);
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 43770a88cdcfa..893398bb2a056 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -53,7 +53,6 @@
#include
#include
#include
-#include "sha1.h"
#include
C_MODE_START
#include "../mysys/my_static.h" // For soundex_map
@@ -172,14 +171,14 @@ String *Item_func_sha::val_str_ascii(String *str)
if (sptr) /* If we got value different from NULL */
{
/* Temporary buffer to store 160bit digest */
- uint8 digest[SHA1_HASH_SIZE];
- compute_sha1_hash(digest, (const char *) sptr->ptr(), sptr->length());
+ uint8 digest[MY_SHA1_HASH_SIZE];
+ my_sha1(digest, (const char *) sptr->ptr(), sptr->length());
/* Ensure that memory is free and we got result */
- if (!str->alloc(SHA1_HASH_SIZE*2))
+ if (!str->alloc(MY_SHA1_HASH_SIZE*2))
{
- array_to_hex((char *) str->ptr(), digest, SHA1_HASH_SIZE);
+ array_to_hex((char *) str->ptr(), digest, MY_SHA1_HASH_SIZE);
str->set_charset(&my_charset_numeric);
- str->length((uint) SHA1_HASH_SIZE*2);
+ str->length((uint) MY_SHA1_HASH_SIZE*2);
null_value=0;
return str;
}
@@ -191,7 +190,7 @@ String *Item_func_sha::val_str_ascii(String *str)
void Item_func_sha::fix_length_and_dec()
{
// size of hex representation of hash
- fix_length_and_charset(SHA1_HASH_SIZE * 2, default_charset());
+ fix_length_and_charset(MY_SHA1_HASH_SIZE * 2, default_charset());
}
String *Item_func_sha2::val_str_ascii(String *str)
diff --git a/sql/password.c b/sql/password.c
index 37d06136d8053..8d05f7d237524 100644
--- a/sql/password.c
+++ b/sql/password.c
@@ -66,7 +66,6 @@
#include
#include
#include
-#include
/************ MySQL 3.23-4.0 authentication routines: untouched ***********/
@@ -389,10 +388,10 @@ void compute_two_stage_sha1_hash(const char *password, size_t pass_len,
uint8 *hash_stage1, uint8 *hash_stage2)
{
/* Stage 1: hash password */
- compute_sha1_hash(hash_stage1, password, pass_len);
+ my_sha1(hash_stage1, password, pass_len);
/* Stage 2 : hash first stage's output. */
- compute_sha1_hash(hash_stage2, (const char *) hash_stage1, SHA1_HASH_SIZE);
+ my_sha1(hash_stage2, (const char *) hash_stage1, MY_SHA1_HASH_SIZE);
}
@@ -404,7 +403,7 @@ void compute_two_stage_sha1_hash(const char *password, size_t pass_len,
is stored in the database.
SYNOPSIS
my_make_scrambled_password()
- buf OUT buffer of size 2*SHA1_HASH_SIZE + 2 to store hex string
+ buf OUT buffer of size 2*MY_SHA1_HASH_SIZE + 2 to store hex string
password IN password string
pass_len IN length of password string
*/
@@ -412,14 +411,14 @@ void compute_two_stage_sha1_hash(const char *password, size_t pass_len,
void my_make_scrambled_password(char *to, const char *password,
size_t pass_len)
{
- uint8 hash_stage2[SHA1_HASH_SIZE];
+ uint8 hash_stage2[MY_SHA1_HASH_SIZE];
/* Two stage SHA1 hash of the password. */
compute_two_stage_sha1_hash(password, pass_len, (uint8 *) to, hash_stage2);
/* convert hash_stage2 to hex string */
*to++= PVERSION41_CHAR;
- octet2hex(to, (const char*) hash_stage2, SHA1_HASH_SIZE);
+ octet2hex(to, (const char*) hash_stage2, MY_SHA1_HASH_SIZE);
}
@@ -430,7 +429,7 @@ void my_make_scrambled_password(char *to, const char *password,
avoid strlen().
SYNOPSIS
make_scrambled_password()
- buf OUT buffer of size 2*SHA1_HASH_SIZE + 2 to store hex string
+ buf OUT buffer of size 2*MY_SHA1_HASH_SIZE + 2 to store hex string
password IN NULL-terminated password string
*/
@@ -451,7 +450,7 @@ void make_scrambled_password(char *to, const char *password)
SYNOPSIS
scramble()
buf OUT store scrambled string here. The buf must be at least
- SHA1_HASH_SIZE bytes long.
+ MY_SHA1_HASH_SIZE bytes long.
message IN random message, must be exactly SCRAMBLE_LENGTH long and
NULL-terminated.
password IN users' password
@@ -460,16 +459,16 @@ void make_scrambled_password(char *to, const char *password)
void
scramble(char *to, const char *message, const char *password)
{
- uint8 hash_stage1[SHA1_HASH_SIZE];
- uint8 hash_stage2[SHA1_HASH_SIZE];
+ uint8 hash_stage1[MY_SHA1_HASH_SIZE];
+ uint8 hash_stage2[MY_SHA1_HASH_SIZE];
/* Two stage SHA1 hash of the password. */
compute_two_stage_sha1_hash(password, strlen(password), hash_stage1,
hash_stage2);
/* create crypt string as sha1(message, hash_stage2) */;
- compute_sha1_hash_multi((uint8 *) to, message, SCRAMBLE_LENGTH,
- (const char *) hash_stage2, SHA1_HASH_SIZE);
+ my_sha1_multi((uint8 *) to, message, SCRAMBLE_LENGTH,
+ (const char *) hash_stage2, MY_SHA1_HASH_SIZE, NULL);
my_crypt(to, (const uchar *) to, hash_stage1, SCRAMBLE_LENGTH);
}
@@ -478,7 +477,7 @@ scramble(char *to, const char *message, const char *password)
Check that scrambled message corresponds to the password; the function
is used by server to check that received reply is authentic.
This function does not check lengths of given strings: message must be
- null-terminated, reply and hash_stage2 must be at least SHA1_HASH_SIZE
+ null-terminated, reply and hash_stage2 must be at least MY_SHA1_HASH_SIZE
long (if not, something fishy is going on).
SYNOPSIS
check_scramble()
@@ -498,19 +497,19 @@ my_bool
check_scramble(const uchar *scramble_arg, const char *message,
const uint8 *hash_stage2)
{
- uint8 buf[SHA1_HASH_SIZE];
- uint8 hash_stage2_reassured[SHA1_HASH_SIZE];
+ uint8 buf[MY_SHA1_HASH_SIZE];
+ uint8 hash_stage2_reassured[MY_SHA1_HASH_SIZE];
/* create key to encrypt scramble */
- compute_sha1_hash_multi(buf, message, SCRAMBLE_LENGTH,
- (const char *) hash_stage2, SHA1_HASH_SIZE);
+ my_sha1_multi(buf, message, SCRAMBLE_LENGTH,
+ (const char *) hash_stage2, MY_SHA1_HASH_SIZE, NULL);
/* encrypt scramble */
my_crypt((char *) buf, buf, scramble_arg, SCRAMBLE_LENGTH);
/* now buf supposedly contains hash_stage1: so we can get hash_stage2 */
- compute_sha1_hash(hash_stage2_reassured, (const char *) buf, SHA1_HASH_SIZE);
+ my_sha1(hash_stage2_reassured, (const char *) buf, MY_SHA1_HASH_SIZE);
- return MY_TEST(memcmp(hash_stage2, hash_stage2_reassured, SHA1_HASH_SIZE));
+ return MY_TEST(memcmp(hash_stage2, hash_stage2_reassured, MY_SHA1_HASH_SIZE));
}
/*
@@ -518,27 +517,27 @@ check_scramble(const uchar *scramble_arg, const char *message,
SYNOPSIS
get_salt_from_password()
- res OUT buf to hold password. Must be at least SHA1_HASH_SIZE
+ res OUT buf to hold password. Must be at least MY_SHA1_HASH_SIZE
bytes long.
password IN 4.1.1 version value of user.password
*/
void get_salt_from_password(uint8 *hash_stage2, const char *password)
{
- hex2octet(hash_stage2, password+1 /* skip '*' */, SHA1_HASH_SIZE * 2);
+ hex2octet(hash_stage2, password+1 /* skip '*' */, MY_SHA1_HASH_SIZE * 2);
}
/*
Convert scrambled password from binary form to asciiz hex string.
SYNOPSIS
make_password_from_salt()
- to OUT store resulting string here, 2*SHA1_HASH_SIZE+2 bytes
+ to OUT store resulting string here, 2*MY_SHA1_HASH_SIZE+2 bytes
salt IN password in salt format
*/
void make_password_from_salt(char *to, const uint8 *hash_stage2)
{
*to++= PVERSION41_CHAR;
- octet2hex(to, (const char*) hash_stage2, SHA1_HASH_SIZE);
+ octet2hex(to, (const char*) hash_stage2, MY_SHA1_HASH_SIZE);
}
From d6a7aece0826e0c115eb21912527c77596c1305e Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Mon, 6 Mar 2017 13:06:03 +0100
Subject: [PATCH 180/226] my_sha2 service
---
include/mysql/plugin.h | 4 +-
include/mysql/plugin_audit.h.pp | 50 +++++++
include/mysql/plugin_auth.h.pp | 50 +++++++
include/mysql/plugin_encryption.h.pp | 50 +++++++
include/mysql/plugin_ftparser.h.pp | 50 +++++++
include/mysql/plugin_password_validation.h.pp | 50 +++++++
include/mysql/service_sha2.h | 130 ++++++++++++++++++
include/mysql/services.h | 3 +-
include/service_versions.h | 3 +-
libservices/CMakeLists.txt | 1 +
libservices/HOWTO | 4 +-
libservices/my_sha2_service.c | 18 +++
mysql-test/r/handlersocket.result | 2 +-
mysql-test/r/plugin.result | 6 +-
.../plugins/r/cracklib_password_check.result | 2 +-
.../suite/plugins/r/show_all_plugins.result | 4 +-
.../plugins/r/simple_password_check.result | 2 +-
mysys_ssl/CMakeLists.txt | 26 ++--
mysys_ssl/my_sha.ic | 4 +-
mysys_ssl/my_sha224.cc | 18 +++
mysys_ssl/my_sha256.cc | 18 +++
mysys_ssl/my_sha384.cc | 18 +++
mysys_ssl/my_sha512.cc | 18 +++
sql/sql_plugin_services.ic | 28 ++++
24 files changed, 534 insertions(+), 25 deletions(-)
create mode 100644 include/mysql/service_sha2.h
create mode 100644 libservices/my_sha2_service.c
create mode 100644 mysys_ssl/my_sha224.cc
create mode 100644 mysys_ssl/my_sha256.cc
create mode 100644 mysys_ssl/my_sha384.cc
create mode 100644 mysys_ssl/my_sha512.cc
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h
index b3c71c65488ce..255d009f0299d 100644
--- a/include/mysql/plugin.h
+++ b/include/mysql/plugin.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2005, 2013, Oracle and/or its affiliates
- Copyright (C) 2009, 2013, Monty Program Ab
+ Copyright (C) 2009, 2017, 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
@@ -75,7 +75,7 @@ typedef struct st_mysql_xid MYSQL_XID;
#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0104
/* MariaDB plugin interface version */
-#define MARIA_PLUGIN_INTERFACE_VERSION 0x010b
+#define MARIA_PLUGIN_INTERFACE_VERSION 0x010c
/*
The allowable types of plugins
diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp
index 24f2c69345d50..d69da9142153c 100644
--- a/include/mysql/plugin_audit.h.pp
+++ b/include/mysql/plugin_audit.h.pp
@@ -98,6 +98,56 @@
} *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);
+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 struct my_sha1_service_st {
void (*my_sha1_type)(unsigned char*, const char*, size_t);
void (*my_sha1_multi_type)(unsigned char*, ...);
diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp
index 10cd10bf9c89c..274208c177dda 100644
--- a/include/mysql/plugin_auth.h.pp
+++ b/include/mysql/plugin_auth.h.pp
@@ -98,6 +98,56 @@
} *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);
+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 struct my_sha1_service_st {
void (*my_sha1_type)(unsigned char*, const char*, size_t);
void (*my_sha1_multi_type)(unsigned char*, ...);
diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp
index 46d3c3d5a5517..604f5386f7dd3 100644
--- a/include/mysql/plugin_encryption.h.pp
+++ b/include/mysql/plugin_encryption.h.pp
@@ -98,6 +98,56 @@
} *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);
+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 struct my_sha1_service_st {
void (*my_sha1_type)(unsigned char*, const char*, size_t);
void (*my_sha1_multi_type)(unsigned char*, ...);
diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp
index 17de800875e80..b11ced22a9678 100644
--- a/include/mysql/plugin_ftparser.h.pp
+++ b/include/mysql/plugin_ftparser.h.pp
@@ -98,6 +98,56 @@
} *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);
+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 struct my_sha1_service_st {
void (*my_sha1_type)(unsigned char*, const char*, size_t);
void (*my_sha1_multi_type)(unsigned char*, ...);
diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp
index 1abdbd30f57de..ecadc9440b014 100644
--- a/include/mysql/plugin_password_validation.h.pp
+++ b/include/mysql/plugin_password_validation.h.pp
@@ -98,6 +98,56 @@
} *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);
+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 struct my_sha1_service_st {
void (*my_sha1_type)(unsigned char*, const char*, size_t);
void (*my_sha1_multi_type)(unsigned char*, ...);
diff --git a/include/mysql/service_sha2.h b/include/mysql/service_sha2.h
new file mode 100644
index 0000000000000..ee4975f7f2445
--- /dev/null
+++ b/include/mysql/service_sha2.h
@@ -0,0 +1,130 @@
+#ifndef MYSQL_SERVICE_SHA2_INCLUDED
+/* Copyright (c) 2017, 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-1301 USA */
+
+/**
+ @file
+ my sha2 service
+
+ Functions to calculate SHA2 hash from a memory buffer
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef MYSQL_ABI_CHECK
+#include
+#endif
+
+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;
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+
+#define my_sha224(A,B,C) my_sha2_service->my_sha224_type(A,B,C)
+#define my_sha224_multi my_sha2_service->my_sha224_multi_type
+#define my_sha224_context_size() my_sha2_service->my_sha224_context_size_type()
+#define my_sha224_init(A) my_sha2_service->my_sha224_init_type(A)
+#define my_sha224_input(A,B,C) my_sha2_service->my_sha224_input_type(A,B,C)
+#define my_sha224_result(A,B) my_sha2_service->my_sha224_result_type(A,B)
+
+#define my_sha256(A,B,C) my_sha2_service->my_sha256_type(A,B,C)
+#define my_sha256_multi my_sha2_service->my_sha256_multi_type
+#define my_sha256_context_size() my_sha2_service->my_sha256_context_size_type()
+#define my_sha256_init(A) my_sha2_service->my_sha256_init_type(A)
+#define my_sha256_input(A,B,C) my_sha2_service->my_sha256_input_type(A,B,C)
+#define my_sha256_result(A,B) my_sha2_service->my_sha256_result_type(A,B)
+
+#define my_sha384(A,B,C) my_sha2_service->my_sha384_type(A,B,C)
+#define my_sha384_multi my_sha2_service->my_sha384_multi_type
+#define my_sha384_context_size() my_sha2_service->my_sha384_context_size_type()
+#define my_sha384_init(A) my_sha2_service->my_sha384_init_type(A)
+#define my_sha384_input(A,B,C) my_sha2_service->my_sha384_input_type(A,B,C)
+#define my_sha384_result(A,B) my_sha2_service->my_sha384_result_type(A,B)
+
+#define my_sha512(A,B,C) my_sha2_service->my_sha512_type(A,B,C)
+#define my_sha512_multi my_sha2_service->my_sha512_multi_type
+#define my_sha512_context_size() my_sha2_service->my_sha512_context_size_type()
+#define my_sha512_init(A) my_sha2_service->my_sha512_init_type(A)
+#define my_sha512_input(A,B,C) my_sha2_service->my_sha512_input_type(A,B,C)
+#define my_sha512_result(A,B) my_sha2_service->my_sha512_result_type(A,B)
+
+#else
+
+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);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#define MYSQL_SERVICE_SHA2_INCLUDED
+#endif
+
diff --git a/include/mysql/services.h b/include/mysql/services.h
index 9d031a9b094d5..89c177ce7ad45 100644
--- a/include/mysql/services.h
+++ b/include/mysql/services.h
@@ -1,6 +1,6 @@
#ifndef MYSQL_SERVICES_INCLUDED
/* Copyright (c) 2009, 2010, Oracle and/or its affiliates.
- Copyright (c) 2012, 2013, Monty Program Ab
+ Copyright (c) 2012, 2017, 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
@@ -26,6 +26,7 @@ extern "C" {
#include
#include
#include
+#include
#include
#include
#include
diff --git a/include/service_versions.h b/include/service_versions.h
index 0f0990d43b31f..9b333127858de 100644
--- a/include/service_versions.h
+++ b/include/service_versions.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2009, 2010, Oracle and/or its affiliates.
- Copyright (c) 2012, 2013, Monty Program Ab
+ Copyright (c) 2012, 2017, 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
@@ -28,6 +28,7 @@
#define VERSION_thd_wait 0x0100
#define VERSION_progress_report 0x0100
#define VERSION_thd_timezone 0x0100
+#define VERSION_my_sha2 0x0100
#define VERSION_my_sha1 0x0101
#define VERSION_my_md5 0x0100
#define VERSION_wsrep 0x0201
diff --git a/libservices/CMakeLists.txt b/libservices/CMakeLists.txt
index 62181a00aa2fd..66ceb3087de1e 100644
--- a/libservices/CMakeLists.txt
+++ b/libservices/CMakeLists.txt
@@ -25,6 +25,7 @@ SET(MYSQLSERVICES_SOURCES
thd_specifics_service.c
progress_report_service.c
debug_sync_service.c
+ my_sha2_service.c
my_sha1_service.c
my_md5_service.c
wsrep_service.c
diff --git a/libservices/HOWTO b/libservices/HOWTO
index 69d96f8aa25fe..6a581bf22e25f 100644
--- a/libservices/HOWTO
+++ b/libservices/HOWTO
@@ -74,7 +74,7 @@ it should also declare all the accompanying data structures, as necessary
#define VERSION_foo 0x0100
==================================================================
-6. create a new file libservices/foo_service.h using the following template:
+6. create a new file libservices/foo_service.c using the following template:
==================================================================
/* GPL header */
#include
@@ -82,7 +82,7 @@ it should also declare all the accompanying data structures, as necessary
==================================================================
7. add the new file to libservices/CMakeLists.txt (MYSQLSERVICES_SOURCES)
-8. Add all new files to repository (bzr add)
+8. Add all new files to repository (git add)
9. and finally, register your service for dynamic linking in
sql/sql_plugin_services.ic as follows:
9.1 fill in the service structure:
diff --git a/libservices/my_sha2_service.c b/libservices/my_sha2_service.c
new file mode 100644
index 0000000000000..aa174e7d1f00b
--- /dev/null
+++ b/libservices/my_sha2_service.c
@@ -0,0 +1,18 @@
+/* Copyright (c) 2017 MariaDB
+ Use is subject to license terms.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+#include
+SERVICE_VERSION my_sha2_service= (void*)VERSION_my_sha2;
diff --git a/mysql-test/r/handlersocket.result b/mysql-test/r/handlersocket.result
index e38de6bf5c2d2..26c77813b26b3 100644
--- a/mysql-test/r/handlersocket.result
+++ b/mysql-test/r/handlersocket.result
@@ -5,7 +5,7 @@ plugin_version 1.0
plugin_status ACTIVE
plugin_type DAEMON
plugin_library handlersocket.so
-plugin_library_version 1.11
+plugin_library_version 1.12
plugin_author higuchi dot akira at dena dot jp
plugin_description Direct access into InnoDB
plugin_license BSD
diff --git a/mysql-test/r/plugin.result b/mysql-test/r/plugin.result
index c23c4f2d8a2a2..f278724cc9a14 100644
--- a/mysql-test/r/plugin.result
+++ b/mysql-test/r/plugin.result
@@ -12,7 +12,7 @@ PLUGIN_STATUS ACTIVE
PLUGIN_TYPE STORAGE ENGINE
PLUGIN_TYPE_VERSION #
PLUGIN_LIBRARY ha_example.so
-PLUGIN_LIBRARY_VERSION 1.11
+PLUGIN_LIBRARY_VERSION 1.12
PLUGIN_AUTHOR Brian Aker, MySQL AB
PLUGIN_DESCRIPTION Example storage engine
PLUGIN_LICENSE GPL
@@ -25,7 +25,7 @@ PLUGIN_STATUS ACTIVE
PLUGIN_TYPE DAEMON
PLUGIN_TYPE_VERSION #
PLUGIN_LIBRARY ha_example.so
-PLUGIN_LIBRARY_VERSION 1.11
+PLUGIN_LIBRARY_VERSION 1.12
PLUGIN_AUTHOR Sergei Golubchik
PLUGIN_DESCRIPTION Unusable Daemon
PLUGIN_LICENSE GPL
@@ -64,7 +64,7 @@ PLUGIN_STATUS DELETED
PLUGIN_TYPE STORAGE ENGINE
PLUGIN_TYPE_VERSION #
PLUGIN_LIBRARY ha_example.so
-PLUGIN_LIBRARY_VERSION 1.11
+PLUGIN_LIBRARY_VERSION 1.12
PLUGIN_AUTHOR Brian Aker, MySQL AB
PLUGIN_DESCRIPTION Example storage engine
PLUGIN_LICENSE GPL
diff --git a/mysql-test/suite/plugins/r/cracklib_password_check.result b/mysql-test/suite/plugins/r/cracklib_password_check.result
index 158a75012403a..479b4b006984f 100644
--- a/mysql-test/suite/plugins/r/cracklib_password_check.result
+++ b/mysql-test/suite/plugins/r/cracklib_password_check.result
@@ -6,7 +6,7 @@ PLUGIN_STATUS ACTIVE
PLUGIN_TYPE PASSWORD VALIDATION
PLUGIN_TYPE_VERSION 1.0
PLUGIN_LIBRARY cracklib_password_check.so
-PLUGIN_LIBRARY_VERSION 1.11
+PLUGIN_LIBRARY_VERSION 1.12
PLUGIN_AUTHOR Sergei Golubchik
PLUGIN_DESCRIPTION Password validation via CrackLib
PLUGIN_LICENSE GPL
diff --git a/mysql-test/suite/plugins/r/show_all_plugins.result b/mysql-test/suite/plugins/r/show_all_plugins.result
index 623e8e9314ba1..c91a360d1d7bc 100644
--- a/mysql-test/suite/plugins/r/show_all_plugins.result
+++ b/mysql-test/suite/plugins/r/show_all_plugins.result
@@ -4,8 +4,8 @@ Variable_name Value
Opened_plugin_libraries 0
select * from information_schema.all_plugins where plugin_library='ha_example.so';
PLUGIN_NAME PLUGIN_VERSION PLUGIN_STATUS PLUGIN_TYPE PLUGIN_TYPE_VERSION PLUGIN_LIBRARY PLUGIN_LIBRARY_VERSION PLUGIN_AUTHOR PLUGIN_DESCRIPTION PLUGIN_LICENSE LOAD_OPTION PLUGIN_MATURITY PLUGIN_AUTH_VERSION
-EXAMPLE 0.1 NOT INSTALLED STORAGE ENGINE MYSQL_VERSION_ID ha_example.so 1.11 Brian Aker, MySQL AB Example storage engine GPL OFF Experimental 0.1
-UNUSABLE 3.14 NOT INSTALLED DAEMON MYSQL_VERSION_ID ha_example.so 1.11 Sergei Golubchik Unusable Daemon GPL OFF Experimental 3.14.15.926
+EXAMPLE 0.1 NOT INSTALLED STORAGE ENGINE MYSQL_VERSION_ID ha_example.so 1.12 Brian Aker, MySQL AB Example storage engine GPL OFF Experimental 0.1
+UNUSABLE 3.14 NOT INSTALLED DAEMON MYSQL_VERSION_ID ha_example.so 1.12 Sergei Golubchik Unusable Daemon GPL OFF Experimental 3.14.15.926
show status like '%libraries%';
Variable_name Value
Opened_plugin_libraries 1
diff --git a/mysql-test/suite/plugins/r/simple_password_check.result b/mysql-test/suite/plugins/r/simple_password_check.result
index 015a26adc87b8..11385bd6b0120 100644
--- a/mysql-test/suite/plugins/r/simple_password_check.result
+++ b/mysql-test/suite/plugins/r/simple_password_check.result
@@ -6,7 +6,7 @@ PLUGIN_STATUS ACTIVE
PLUGIN_TYPE PASSWORD VALIDATION
PLUGIN_TYPE_VERSION 1.0
PLUGIN_LIBRARY simple_password_check.so
-PLUGIN_LIBRARY_VERSION 1.11
+PLUGIN_LIBRARY_VERSION 1.12
PLUGIN_AUTHOR Sergei Golubchik
PLUGIN_DESCRIPTION Simple password strength checks
PLUGIN_LICENSE GPL
diff --git a/mysys_ssl/CMakeLists.txt b/mysys_ssl/CMakeLists.txt
index b00213bc49287..7251d8777f8af 100644
--- a/mysys_ssl/CMakeLists.txt
+++ b/mysys_ssl/CMakeLists.txt
@@ -21,24 +21,30 @@ IF(SSL_DEFINES)
ADD_DEFINITIONS(${SSL_DEFINES})
ENDIF()
+SET(MYSYS_SSL_HIDDEN_SOURCES
+ my_sha1.cc
+ my_sha224.cc
+ my_sha256.cc
+ my_sha384.cc
+ my_sha512.cc
+ my_sha2.cc
+ my_md5.cc
+ )
+
+SET(MYSYS_SSL_SOURCES
+ ${MYSYS_SSL_HIDDEN_SOURCES}
+ my_crypt.cc
+ )
+
# We do RESTRICT_SYMBOL_EXPORTS(yassl) elsewhere.
# In order to get correct symbol visibility, these files
# must be compiled with "-fvisibility=hidden"
IF(WITH_SSL STREQUAL "bundled" AND HAVE_VISIBILITY_HIDDEN)
SET_SOURCE_FILES_PROPERTIES(
- my_md5.cc
- my_sha1.cc
- my_sha2.cc
+ ${MYSYS_SSL_HIDDEN_SOURCES}
PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
ENDIF()
-SET(MYSYS_SSL_SOURCES
- my_sha1.cc
- my_sha2.cc
- my_md5.cc
- my_crypt.cc
- )
-
ADD_CONVENIENCE_LIBRARY(mysys_ssl ${MYSYS_SSL_SOURCES})
TARGET_LINK_LIBRARIES(mysys_ssl dbug strings ${SSL_LIBRARIES})
DTRACE_INSTRUMENT(mysys_ssl)
diff --git a/mysys_ssl/my_sha.ic b/mysys_ssl/my_sha.ic
index 5a95c9c468227..a7ec8bad593f6 100644
--- a/mysys_ssl/my_sha.ic
+++ b/mysys_ssl/my_sha.ic
@@ -26,7 +26,7 @@
#include
#include
-#define HASH_SIZE 20
+#define HASH_SIZE (NUM > 1 ? NUM/8 : 20)
#if defined(HAVE_YASSL)
#include "sha.hpp"
@@ -66,6 +66,8 @@ static void sha_result(CONTEXT *context, uchar digest[HASH_SIZE])
#define yCONTEXT(y) xCONTEXT(y)
#define CONTEXT yCONTEXT(NUM)
#define SHA1_CTX SHA_CTX
+#define SHA224_CTX SHA256_CTX
+#define SHA384_CTX SHA512_CTX
#define xSHA_Init(x) SHA ## x ## _Init
#define xSHA_Update(x) SHA ## x ## _Update
diff --git a/mysys_ssl/my_sha224.cc b/mysys_ssl/my_sha224.cc
new file mode 100644
index 0000000000000..7e8b481256b89
--- /dev/null
+++ b/mysys_ssl/my_sha224.cc
@@ -0,0 +1,18 @@
+/* Copyright (c) 2017, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#define NUM 224
+
+#include "my_sha.ic"
diff --git a/mysys_ssl/my_sha256.cc b/mysys_ssl/my_sha256.cc
new file mode 100644
index 0000000000000..8c1a466200966
--- /dev/null
+++ b/mysys_ssl/my_sha256.cc
@@ -0,0 +1,18 @@
+/* Copyright (c) 2017, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#define NUM 256
+
+#include "my_sha.ic"
diff --git a/mysys_ssl/my_sha384.cc b/mysys_ssl/my_sha384.cc
new file mode 100644
index 0000000000000..3bad6b39248c8
--- /dev/null
+++ b/mysys_ssl/my_sha384.cc
@@ -0,0 +1,18 @@
+/* Copyright (c) 2017, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#define NUM 384
+
+#include "my_sha.ic"
diff --git a/mysys_ssl/my_sha512.cc b/mysys_ssl/my_sha512.cc
new file mode 100644
index 0000000000000..8077efd3b57bd
--- /dev/null
+++ b/mysys_ssl/my_sha512.cc
@@ -0,0 +1,18 @@
+/* Copyright (c) 2017, 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,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#define NUM 512
+
+#include "my_sha.ic"
diff --git a/sql/sql_plugin_services.ic b/sql/sql_plugin_services.ic
index c3dfde18ab655..e4a9732e8885c 100644
--- a/sql/sql_plugin_services.ic
+++ b/sql/sql_plugin_services.ic
@@ -60,6 +60,33 @@ static struct thd_timezone_service_st thd_timezone_handler= {
thd_gmt_sec_to_TIME
};
+static struct my_sha2_service_st my_sha2_handler = {
+ my_sha224,
+ my_sha224_multi,
+ my_sha224_context_size,
+ my_sha224_init,
+ my_sha224_input,
+ my_sha224_result,
+ my_sha256,
+ my_sha256_multi,
+ my_sha256_context_size,
+ my_sha256_init,
+ my_sha256_input,
+ my_sha256_result,
+ my_sha384,
+ my_sha384_multi,
+ my_sha384_context_size,
+ my_sha384_init,
+ my_sha384_input,
+ my_sha384_result,
+ my_sha512,
+ my_sha512_multi,
+ my_sha512_context_size,
+ my_sha512_init,
+ my_sha512_input,
+ my_sha512_result,
+};
+
static struct my_sha1_service_st my_sha1_handler = {
my_sha1,
my_sha1_multi,
@@ -164,6 +191,7 @@ static struct st_service_ref list_of_services[]=
{ "debug_sync_service", VERSION_debug_sync, 0 }, // updated in plugin_init()
{ "thd_kill_statement_service", VERSION_kill_statement, &thd_kill_statement_handler },
{ "thd_timezone_service", VERSION_thd_timezone, &thd_timezone_handler },
+ { "my_sha2_service", VERSION_my_sha2, &my_sha2_handler},
{ "my_sha1_service", VERSION_my_sha1, &my_sha1_handler},
{ "my_md5_service", VERSION_my_md5, &my_md5_handler},
{ "logger_service", VERSION_logger, &logger_service_handler },
From 70a2efde0352052fce5a44481055542e0b050048 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Mon, 6 Mar 2017 15:31:25 +0100
Subject: [PATCH 181/226] remove old API for SHA2
---
include/sha2.h | 72 ----------------------------------------
libmysqld/CMakeLists.txt | 2 +-
mysys_ssl/CMakeLists.txt | 1 -
mysys_ssl/my_sha2.cc | 68 -------------------------------------
sql/CMakeLists.txt | 2 +-
sql/item_strfunc.cc | 72 ++++++++++------------------------------
sql/sha2.cc | 68 -------------------------------------
7 files changed, 19 insertions(+), 266 deletions(-)
delete mode 100644 include/sha2.h
delete mode 100644 mysys_ssl/my_sha2.cc
delete mode 100644 sql/sha2.cc
diff --git a/include/sha2.h b/include/sha2.h
deleted file mode 100644
index 737658e9ced9a..0000000000000
--- a/include/sha2.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* Copyright (c) 2007, 2010, 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, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
-
-#ifndef included_sha2_h
-#define included_sha2_h
-
-#include
-
-#if defined(HAVE_YASSL) || defined(HAVE_OPENSSL)
-
-# ifdef HAVE_STDDEF_H
-# include
-# endif
-
-# ifndef HAVE_YASSL
-# include
-
-# else
-
-#include "../extra/yassl/taocrypt/include/sha.hpp"
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-#ifndef SHA512_DIGEST_LENGTH
-#define SHA512_DIGEST_LENGTH TaoCrypt::SHA512::DIGEST_SIZE
-#endif
-
-#ifndef SHA384_DIGEST_LENGTH
-#define SHA384_DIGEST_LENGTH TaoCrypt::SHA384::DIGEST_SIZE
-#endif
-
-#ifndef SHA256_DIGEST_LENGTH
-#define SHA256_DIGEST_LENGTH TaoCrypt::SHA256::DIGEST_SIZE
-#endif
-
-#ifndef SHA224_DIGEST_LENGTH
-#define SHA224_DIGEST_LENGTH TaoCrypt::SHA224::DIGEST_SIZE
-#endif
-
-#define GEN_YASSL_SHA2_BRIDGE(size) \
-unsigned char* SHA##size(const unsigned char *input_ptr, size_t input_length, \
- char unsigned *output_ptr);
-
-GEN_YASSL_SHA2_BRIDGE(512);
-GEN_YASSL_SHA2_BRIDGE(384);
-GEN_YASSL_SHA2_BRIDGE(256);
-GEN_YASSL_SHA2_BRIDGE(224);
-
-#undef GEN_YASSL_SHA2_BRIDGE
-
-# ifdef __cplusplus
-}
-# endif
-
-# endif /* HAVE_YASSL */
-
-#endif /* HAVE_OPENSSL || HAVE_YASSL */
-#endif /* included_sha2_h */
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index 515105f49e801..07bee9848b642 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -56,7 +56,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../sql/net_serv.cc ../sql/opt_range.cc ../sql/opt_sum.cc
../sql/parse_file.cc ../sql/procedure.cc ../sql/protocol.cc
../sql/records.cc ../sql/repl_failsafe.cc ../sql/rpl_filter.cc
- ../sql/rpl_record.cc ../sql/sha2.cc ../sql/des_key_file.cc
+ ../sql/rpl_record.cc ../sql/des_key_file.cc
../sql/rpl_injector.cc ../sql/set_var.cc ../sql/spatial.cc
../sql/sp_cache.cc ../sql/sp.cc ../sql/sp_head.cc
../sql/sp_pcontext.cc ../sql/sp_rcontext.cc ../sql/sql_acl.cc
diff --git a/mysys_ssl/CMakeLists.txt b/mysys_ssl/CMakeLists.txt
index 7251d8777f8af..4f6f7458c5b91 100644
--- a/mysys_ssl/CMakeLists.txt
+++ b/mysys_ssl/CMakeLists.txt
@@ -27,7 +27,6 @@ SET(MYSYS_SSL_HIDDEN_SOURCES
my_sha256.cc
my_sha384.cc
my_sha512.cc
- my_sha2.cc
my_md5.cc
)
diff --git a/mysys_ssl/my_sha2.cc b/mysys_ssl/my_sha2.cc
deleted file mode 100644
index 00200337f088f..0000000000000
--- a/mysys_ssl/my_sha2.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Copyright (c) 2007, 2012, 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 */
-
-
-/**
- @file
- A compatibility layer to our built-in SSL implementation, to mimic the
- oft-used external library, OpenSSL.
-*/
-
-#include
-#include
-
-#ifdef HAVE_YASSL
-
-/*
- If TaoCrypt::SHA512 or ::SHA384 are not defined (but ::SHA256 is), it's
- probably that neither of config.h's SIZEOF_LONG or SIZEOF_LONG_LONG are
- 64 bits long. At present, both OpenSSL and YaSSL require 64-bit integers
- for SHA-512. (The SIZEOF_* definitions come from autoconf's config.h .)
-*/
-
-# define GEN_YASSL_SHA2_BRIDGE(size) \
-unsigned char* SHA##size(const unsigned char *input_ptr, size_t input_length, \
- char unsigned *output_ptr) { \
- TaoCrypt::SHA##size hasher; \
- \
- hasher.Update(input_ptr, input_length); \
- hasher.Final(output_ptr); \
- return(output_ptr); \
-}
-
-
-/**
- @fn SHA512
- @fn SHA384
- @fn SHA256
- @fn SHA224
-
- Instantiate an hash object, fill in the cleartext value, compute the digest,
- and extract the result from the object.
-
- (Generate the functions. See similar .h code for the prototypes.)
-*/
-# ifndef OPENSSL_NO_SHA512
-GEN_YASSL_SHA2_BRIDGE(512);
-GEN_YASSL_SHA2_BRIDGE(384);
-# else
-# warning Some SHA2 functionality is missing. See OPENSSL_NO_SHA512.
-# endif
-GEN_YASSL_SHA2_BRIDGE(256);
-GEN_YASSL_SHA2_BRIDGE(224);
-
-# undef GEN_YASSL_SHA2_BRIDGE
-
-#endif /* HAVE_YASSL */
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 46eb4bec3ccaf..8944233cb5b0e 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -81,7 +81,7 @@ SET (SQL_SOURCE
../sql-common/client.c compat56.cc derror.cc des_key_file.cc
discover.cc ../libmysql/errmsg.c field.cc field_conv.cc
filesort_utils.cc
- filesort.cc gstream.cc sha2.cc
+ filesort.cc gstream.cc
signal_handler.cc
handler.cc hash_filo.h
hostname.cc init.cc item.cc item_buff.cc item_cmpfunc.cc
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 893398bb2a056..84cf21bd0d3d6 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -33,9 +33,6 @@
#include // HAVE_*
-/* May include caustic 3rd-party defs. Use early, so it can override nothing */
-#include "sha2.h"
-
#include "sql_priv.h"
/*
It is necessary to include set_var.h instead of item.h because there
@@ -196,12 +193,10 @@ void Item_func_sha::fix_length_and_dec()
String *Item_func_sha2::val_str_ascii(String *str)
{
DBUG_ASSERT(fixed == 1);
-#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
- unsigned char digest_buf[SHA512_DIGEST_LENGTH];
+ unsigned char digest_buf[512/8]; // enough for SHA512
String *input_string;
- unsigned char *input_ptr;
+ const char *input_ptr;
size_t input_len;
- uint digest_length= 0;
str->set_charset(&my_charset_bin);
@@ -216,31 +211,26 @@ String *Item_func_sha2::val_str_ascii(String *str)
if (null_value)
return (String *) NULL;
- input_ptr= (unsigned char *) input_string->ptr();
+ input_ptr= input_string->ptr();
input_len= input_string->length();
- switch ((uint) args[1]->val_int()) {
-#ifndef OPENSSL_NO_SHA512
+ longlong digest_length= args[1]->val_int();
+ switch (digest_length) {
case 512:
- digest_length= SHA512_DIGEST_LENGTH;
- (void) SHA512(input_ptr, input_len, digest_buf);
+ my_sha512(digest_buf, input_ptr, input_len);
break;
case 384:
- digest_length= SHA384_DIGEST_LENGTH;
- (void) SHA384(input_ptr, input_len, digest_buf);
+ my_sha384(digest_buf, input_ptr, input_len);
break;
-#endif
-#ifndef OPENSSL_NO_SHA256
case 224:
- digest_length= SHA224_DIGEST_LENGTH;
- (void) SHA224(input_ptr, input_len, digest_buf);
+ my_sha224(digest_buf, input_ptr, input_len);
break;
- case 256:
case 0: // SHA-256 is the default
- digest_length= SHA256_DIGEST_LENGTH;
- (void) SHA256(input_ptr, input_len, digest_buf);
+ digest_length= 256;
+ /* fall trough */
+ case 256:
+ my_sha256(digest_buf, input_ptr, input_len);
break;
-#endif
default:
if (!args[1]->const_item())
{
@@ -254,6 +244,7 @@ String *Item_func_sha2::val_str_ascii(String *str)
null_value= TRUE;
return NULL;
}
+ digest_length/= 8; /* bits to bytes */
/*
Since we're subverting the usual String methods, we must make sure that
@@ -269,17 +260,6 @@ String *Item_func_sha2::val_str_ascii(String *str)
null_value= FALSE;
return str;
-
-#else
- THD *thd= current_thd;
- push_warning_printf(thd,
- Sql_condition::WARN_LEVEL_WARN,
- ER_FEATURE_DISABLED,
- ER_THD(thd, ER_FEATURE_DISABLED),
- "sha2", "--with-ssl");
- null_value= TRUE;
- return (String *) NULL;
-#endif /* defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) */
}
@@ -288,27 +268,18 @@ void Item_func_sha2::fix_length_and_dec()
maybe_null= 1;
max_length = 0;
-#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
int sha_variant= args[1]->const_item() ? args[1]->val_int() : 512;
switch (sha_variant) {
-#ifndef OPENSSL_NO_SHA512
+ case 0: // SHA-256 is the default
+ sha_variant= 256;
+ /* fall trough */
case 512:
- fix_length_and_charset(SHA512_DIGEST_LENGTH * 2, default_charset());
- break;
case 384:
- fix_length_and_charset(SHA384_DIGEST_LENGTH * 2, default_charset());
- break;
-#endif
-#ifndef OPENSSL_NO_SHA256
case 256:
- case 0: // SHA-256 is the default
- fix_length_and_charset(SHA256_DIGEST_LENGTH * 2, default_charset());
- break;
case 224:
- fix_length_and_charset(SHA224_DIGEST_LENGTH * 2, default_charset());
+ fix_length_and_charset(sha_variant/8 * 2, default_charset());
break;
-#endif
default:
THD *thd= current_thd;
push_warning_printf(thd,
@@ -317,15 +288,6 @@ void Item_func_sha2::fix_length_and_dec()
ER_THD(thd, ER_WRONG_PARAMETERS_TO_NATIVE_FCT),
"sha2");
}
-
-#else
- THD *thd= current_thd;
- push_warning_printf(thd,
- Sql_condition::WARN_LEVEL_WARN,
- ER_FEATURE_DISABLED,
- ER_THD(thd, ER_FEATURE_DISABLED),
- "sha2", "--with-ssl");
-#endif /* defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) */
}
/* Implementation of AES encryption routines */
diff --git a/sql/sha2.cc b/sql/sha2.cc
deleted file mode 100644
index f220197417280..0000000000000
--- a/sql/sha2.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Copyright (c) 2007, 2010, 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, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
-
-
-/**
- @file
- A compatibility layer to our built-in SSL implementation, to mimic the
- oft-used external library, OpenSSL.
-*/
-
-#include
-#include
-
-#ifdef HAVE_YASSL
-
-/*
- If TaoCrypt::SHA512 or ::SHA384 are not defined (but ::SHA256 is), it's
- probably that neither of config.h's SIZEOF_LONG or SIZEOF_LONG_LONG are
- 64 bits long. At present, both OpenSSL and YaSSL require 64-bit integers
- for SHA-512. (The SIZEOF_* definitions come from autoconf's config.h .)
-*/
-
-# define GEN_YASSL_SHA2_BRIDGE(size) \
-unsigned char* SHA##size(const unsigned char *input_ptr, size_t input_length, \
- char unsigned *output_ptr) { \
- TaoCrypt::SHA##size hasher; \
- \
- hasher.Update(input_ptr, input_length); \
- hasher.Final(output_ptr); \
- return(output_ptr); \
-}
-
-
-/**
- @fn SHA512
- @fn SHA384
- @fn SHA256
- @fn SHA224
-
- Instantiate an hash object, fill in the cleartext value, compute the digest,
- and extract the result from the object.
-
- (Generate the functions. See similar .h code for the prototypes.)
-*/
-# ifndef OPENSSL_NO_SHA512
-GEN_YASSL_SHA2_BRIDGE(512);
-GEN_YASSL_SHA2_BRIDGE(384);
-# else
-# warning Some SHA2 functionality is missing. See OPENSSL_NO_SHA512.
-# endif
-GEN_YASSL_SHA2_BRIDGE(256);
-GEN_YASSL_SHA2_BRIDGE(224);
-
-# undef GEN_YASSL_SHA2_BRIDGE
-
-#endif /* HAVE_YASSL */
From 051851b9a673e38d12612ea92d8a8913b8f0ca45 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Mon, 6 Mar 2017 17:05:03 +0100
Subject: [PATCH 182/226] base64 service
---
include/base64.h | 62 --------------
include/mysql/plugin_audit.h.pp | 16 ++++
include/mysql/plugin_auth.h.pp | 16 ++++
include/mysql/plugin_encryption.h.pp | 16 ++++
include/mysql/plugin_ftparser.h.pp | 16 ++++
include/mysql/plugin_password_validation.h.pp | 16 ++++
include/mysql/service_base64.h | 82 +++++++++++++++++++
include/mysql/services.h | 1 +
include/service_versions.h | 1 +
libservices/CMakeLists.txt | 1 +
libservices/base64_service.c | 18 ++++
mysys/base64.c | 1 -
plugin/feedback/utils.cc | 2 -
sql/item_strfunc.cc | 1 -
sql/log_event.cc | 1 -
sql/sql_binlog.cc | 1 -
sql/sql_plugin_services.ic | 10 +++
unittest/mysys/base64-t.c | 1 -
18 files changed, 193 insertions(+), 69 deletions(-)
delete mode 100644 include/base64.h
create mode 100644 include/mysql/service_base64.h
create mode 100644 libservices/base64_service.c
diff --git a/include/base64.h b/include/base64.h
deleted file mode 100644
index 9a843b5088e9c..0000000000000
--- a/include/base64.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Copyright (c) 2003-2006 MySQL AB
- Use is subject to license terms
-
- 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 Street, Fifth Floor, Boston, MA 02110-1301, USA */
-
-#ifndef __BASE64_H_INCLUDED__
-#define __BASE64_H_INCLUDED__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- Calculate how much memory needed for dst of base64_encode()
-*/
-int base64_needed_encoded_length(int length_of_data);
-
-/*
- Maximum length base64_encode_needed_length() can accept with no overflow.
-*/
-int base64_encode_max_arg_length(void);
-
-/*
- Calculate how much memory needed for dst of base64_decode()
-*/
-int base64_needed_decoded_length(int length_of_encoded_data);
-
-/*
- Maximum length base64_decode_needed_length() can accept with no overflow.
-*/
-int base64_decode_max_arg_length();
-
-/*
- Encode data as a base64 string
-*/
-int base64_encode(const void *src, size_t src_len, char *dst);
-
-/*
- Decode a base64 string into data
-*/
-int base64_decode(const char *src, size_t src_len,
- void *dst, const char **end_ptr, int flags);
-
-/* Allow multuple chunks 'AAA= AA== AA==', binlog uses this */
-#define MY_BASE64_DECODE_ALLOW_MULTIPLE_CHUNKS 1
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* !__BASE64_H_INCLUDED__ */
diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp
index d69da9142153c..309bae1a0b0c2 100644
--- a/include/mysql/plugin_audit.h.pp
+++ b/include/mysql/plugin_audit.h.pp
@@ -176,6 +176,22 @@
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 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 base64_needed_encoded_length(int length_of_data);
+int base64_encode_max_arg_length(void);
+int base64_needed_decoded_length(int length_of_encoded_data);
+int base64_decode_max_arg_length();
+int base64_encode(const void *src, size_t src_len, char *dst);
+int base64_decode(const char *src, size_t src_len,
+ void *dst, const char **end_ptr, int flags);
typedef struct logger_handle_st LOGGER_HANDLE;
extern struct logger_service_st {
void (*logger_init_mutexes)();
diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp
index 274208c177dda..4c28ad4035e5d 100644
--- a/include/mysql/plugin_auth.h.pp
+++ b/include/mysql/plugin_auth.h.pp
@@ -176,6 +176,22 @@
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 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 base64_needed_encoded_length(int length_of_data);
+int base64_encode_max_arg_length(void);
+int base64_needed_decoded_length(int length_of_encoded_data);
+int base64_decode_max_arg_length();
+int base64_encode(const void *src, size_t src_len, char *dst);
+int base64_decode(const char *src, size_t src_len,
+ void *dst, const char **end_ptr, int flags);
typedef struct logger_handle_st LOGGER_HANDLE;
extern struct logger_service_st {
void (*logger_init_mutexes)();
diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp
index 604f5386f7dd3..86d4427bc036d 100644
--- a/include/mysql/plugin_encryption.h.pp
+++ b/include/mysql/plugin_encryption.h.pp
@@ -176,6 +176,22 @@
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 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 base64_needed_encoded_length(int length_of_data);
+int base64_encode_max_arg_length(void);
+int base64_needed_decoded_length(int length_of_encoded_data);
+int base64_decode_max_arg_length();
+int base64_encode(const void *src, size_t src_len, char *dst);
+int base64_decode(const char *src, size_t src_len,
+ void *dst, const char **end_ptr, int flags);
typedef struct logger_handle_st LOGGER_HANDLE;
extern struct logger_service_st {
void (*logger_init_mutexes)();
diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp
index b11ced22a9678..595735f0cf58b 100644
--- a/include/mysql/plugin_ftparser.h.pp
+++ b/include/mysql/plugin_ftparser.h.pp
@@ -176,6 +176,22 @@
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 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 base64_needed_encoded_length(int length_of_data);
+int base64_encode_max_arg_length(void);
+int base64_needed_decoded_length(int length_of_encoded_data);
+int base64_decode_max_arg_length();
+int base64_encode(const void *src, size_t src_len, char *dst);
+int base64_decode(const char *src, size_t src_len,
+ void *dst, const char **end_ptr, int flags);
typedef struct logger_handle_st LOGGER_HANDLE;
extern struct logger_service_st {
void (*logger_init_mutexes)();
diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp
index ecadc9440b014..23a56273e5104 100644
--- a/include/mysql/plugin_password_validation.h.pp
+++ b/include/mysql/plugin_password_validation.h.pp
@@ -176,6 +176,22 @@
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 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 base64_needed_encoded_length(int length_of_data);
+int base64_encode_max_arg_length(void);
+int base64_needed_decoded_length(int length_of_encoded_data);
+int base64_decode_max_arg_length();
+int base64_encode(const void *src, size_t src_len, char *dst);
+int base64_decode(const char *src, size_t src_len,
+ void *dst, const char **end_ptr, int flags);
typedef struct logger_handle_st LOGGER_HANDLE;
extern struct logger_service_st {
void (*logger_init_mutexes)();
diff --git a/include/mysql/service_base64.h b/include/mysql/service_base64.h
new file mode 100644
index 0000000000000..6020daed6cbb8
--- /dev/null
+++ b/include/mysql/service_base64.h
@@ -0,0 +1,82 @@
+#ifndef MYSQL_SERVICE_BASE64_INCLUDED
+/* Copyright (c) 2017, 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-1301 USA */
+
+/**
+ @file
+ my base64 service
+
+ Functions for base64 en- and decoding
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef MYSQL_ABI_CHECK
+#include
+#endif
+
+/* Allow multuple chunks 'AAA= AA== AA==', binlog uses this */
+#define MY_BASE64_DECODE_ALLOW_MULTIPLE_CHUNKS 1
+
+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;
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+
+#define base64_needed_encoded_length(A) base64_service->base64_needed_encoded_length_ptr(A)
+#define base64_encode_max_arg_length() base64_service->base64_encode_max_arg_length_ptr()
+#define base64_needed_decoded_length(A) base64_service->base64_needed_decoded_length_ptr(A)
+#define base64_decode_max_arg_length() base64_service->base64_decode_max_arg_length_ptr()
+#define base64_encode(A,B,C) base64_service->base64_encode_ptr(A,B,C)
+#define base64_decode(A,B,C,D,E) base64_service->base64_decode_ptr(A,B,C,D,E)
+
+#else
+
+/* Calculate how much memory needed for dst of base64_encode() */
+int base64_needed_encoded_length(int length_of_data);
+
+/* Maximum length base64_encode_needed_length() can accept with no overflow. */
+int base64_encode_max_arg_length(void);
+
+/* Calculate how much memory needed for dst of base64_decode() */
+int base64_needed_decoded_length(int length_of_encoded_data);
+
+/* Maximum length base64_decode_needed_length() can accept with no overflow. */
+int base64_decode_max_arg_length();
+
+/* Encode data as a base64 string */
+int base64_encode(const void *src, size_t src_len, char *dst);
+
+/* Decode a base64 string into data */
+int base64_decode(const char *src, size_t src_len,
+ void *dst, const char **end_ptr, int flags);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#define MYSQL_SERVICE_BASE64_INCLUDED
+#endif
diff --git a/include/mysql/services.h b/include/mysql/services.h
index 89c177ce7ad45..3ba0ce6511c8e 100644
--- a/include/mysql/services.h
+++ b/include/mysql/services.h
@@ -29,6 +29,7 @@ extern "C" {
#include
#include
#include
+#include
#include
#include
#include
diff --git a/include/service_versions.h b/include/service_versions.h
index 9b333127858de..f78697d277c29 100644
--- a/include/service_versions.h
+++ b/include/service_versions.h
@@ -33,6 +33,7 @@
#define VERSION_my_md5 0x0100
#define VERSION_wsrep 0x0201
#define VERSION_logger 0x0100
+#define VERSION_base64 0x0100
#define VERSION_thd_autoinc 0x0100
#define VERSION_thd_error_context 0x0100
#define VERSION_thd_specifics 0x0100
diff --git a/libservices/CMakeLists.txt b/libservices/CMakeLists.txt
index 66ceb3087de1e..04f3cb4b69b04 100644
--- a/libservices/CMakeLists.txt
+++ b/libservices/CMakeLists.txt
@@ -28,6 +28,7 @@ SET(MYSQLSERVICES_SOURCES
my_sha2_service.c
my_sha1_service.c
my_md5_service.c
+ base64_service.c
wsrep_service.c
encryption_service.c
encryption_scheme_service.c
diff --git a/libservices/base64_service.c b/libservices/base64_service.c
new file mode 100644
index 0000000000000..af35ccd2a1cba
--- /dev/null
+++ b/libservices/base64_service.c
@@ -0,0 +1,18 @@
+/* Copyright (c) 2017 MariaDB
+ Use is subject to license terms.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
+#include
+SERVICE_VERSION base64_service= (void*)VERSION_base64;
diff --git a/mysys/base64.c b/mysys/base64.c
index 265b2f22aaddb..04411418857a2 100644
--- a/mysys/base64.c
+++ b/mysys/base64.c
@@ -17,7 +17,6 @@
#include
#include /* strchr() */
#include /* my_isspace() */
-#include
#ifndef MAIN
diff --git a/plugin/feedback/utils.cc b/plugin/feedback/utils.cc
index 669ed9a442711..0998721c868a9 100644
--- a/plugin/feedback/utils.cc
+++ b/plugin/feedback/utils.cc
@@ -19,8 +19,6 @@
#include
#endif
-#include
-
#if defined (_WIN32)
#define HAVE_SYS_UTSNAME_H
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 84cf21bd0d3d6..fb057f20dcf2b 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -48,7 +48,6 @@
#include "password.h" // my_make_scrambled_password,
// my_make_scrambled_password_323
#include
-#include
#include
#include
C_MODE_START
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 13a271d98da3f..3e2592808b1c4 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -46,7 +46,6 @@
#include "wsrep_mysqld.h"
#endif /* MYSQL_CLIENT */
-#include
#include
#include "rpl_utility.h"
#include "rpl_constants.h"
diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc
index f0465cdf5bfbf..91cf038907eb5 100644
--- a/sql/sql_binlog.cc
+++ b/sql/sql_binlog.cc
@@ -20,7 +20,6 @@
#include "sql_parse.h" // check_global_access
#include "sql_acl.h" // *_ACL
#include "rpl_rli.h"
-#include "base64.h"
#include "slave.h" // apply_event_and_update_pos
#include "log_event.h" // Format_description_log_event,
// EVENT_LEN_OFFSET,
diff --git a/sql/sql_plugin_services.ic b/sql/sql_plugin_services.ic
index e4a9732e8885c..e08870e9f985a 100644
--- a/sql/sql_plugin_services.ic
+++ b/sql/sql_plugin_services.ic
@@ -119,6 +119,15 @@ static struct thd_autoinc_service_st thd_autoinc_handler= {
thd_get_autoinc
};
+static struct base64_service_st base64_handler= {
+ base64_needed_encoded_length,
+ base64_encode_max_arg_length,
+ base64_needed_decoded_length,
+ base64_decode_max_arg_length,
+ base64_encode,
+ base64_decode
+};
+
static struct thd_error_context_service_st thd_error_conext_handler= {
thd_get_error_message,
thd_get_error_number,
@@ -195,6 +204,7 @@ static struct st_service_ref list_of_services[]=
{ "my_sha1_service", VERSION_my_sha1, &my_sha1_handler},
{ "my_md5_service", VERSION_my_md5, &my_md5_handler},
{ "logger_service", VERSION_logger, &logger_service_handler },
+ { "base64_service", VERSION_base64, &base64_handler },
{ "thd_autoinc_service", VERSION_thd_autoinc, &thd_autoinc_handler },
{ "wsrep_service", VERSION_wsrep, &wsrep_handler },
{ "encryption_service", VERSION_encryption, &encryption_handler },
diff --git a/unittest/mysys/base64-t.c b/unittest/mysys/base64-t.c
index 1cf54f9b67310..4561606936a9e 100644
--- a/unittest/mysys/base64-t.c
+++ b/unittest/mysys/base64-t.c
@@ -16,7 +16,6 @@
#include
#include
-#include
#include
#include
From 6305533de2fd38d43c149d4d7c847f65d68205c7 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Mon, 6 Mar 2017 17:32:18 +0100
Subject: [PATCH 183/226] Auth Plugin API: add THD to MYSQL_SERVER_AUTH_INFO
so that auth plugins could use various thd services
---
include/mysql/plugin_auth.h | 7 ++-
include/mysql/plugin_auth.h.pp | 1 +
sql/sql_acl.cc | 79 +++++++++++++++++-----------------
3 files changed, 46 insertions(+), 41 deletions(-)
diff --git a/include/mysql/plugin_auth.h b/include/mysql/plugin_auth.h
index d776ed79a61f5..807bfd4e65234 100644
--- a/include/mysql/plugin_auth.h
+++ b/include/mysql/plugin_auth.h
@@ -27,7 +27,7 @@
#include
-#define MYSQL_AUTHENTICATION_INTERFACE_VERSION 0x0200
+#define MYSQL_AUTHENTICATION_INTERFACE_VERSION 0x0201
#include
@@ -105,6 +105,11 @@ typedef struct st_mysql_server_auth_info
*/
unsigned int host_or_ip_length;
+ /**
+ Current THD pointer (to use with various services)
+ */
+ MYSQL_THD thd;
+
} MYSQL_SERVER_AUTH_INFO;
/**
diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp
index 4c28ad4035e5d..63ad776314d51 100644
--- a/include/mysql/plugin_auth.h.pp
+++ b/include/mysql/plugin_auth.h.pp
@@ -504,6 +504,7 @@
int password_used;
const char *host_or_ip;
unsigned int host_or_ip_length;
+ void* thd;
} MYSQL_SERVER_AUTH_INFO;
struct st_mysql_auth
{
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index cb4c3cb1049f9..142e2ecc198ba 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -11184,7 +11184,6 @@ get_cached_table_access(GRANT_INTERNAL_INFO *grant_internal_info,
struct MPVIO_EXT :public MYSQL_PLUGIN_VIO
{
MYSQL_SERVER_AUTH_INFO auth_info;
- THD *thd;
ACL_USER *acl_user; ///< a copy, independent from acl_users array
plugin_ref plugin; ///< what plugin we're under
LEX_STRING db; ///< db name from the handshake packet
@@ -11264,7 +11263,7 @@ static bool send_server_handshake_packet(MPVIO_EXT *mpvio,
DBUG_ASSERT(mpvio->status == MPVIO_EXT::FAILURE);
DBUG_ASSERT(data_len <= 255);
- THD *thd= mpvio->thd;
+ THD *thd= mpvio->auth_info.thd;
char *buff= (char *) my_alloca(1 + SERVER_VERSION_LENGTH + 1 + data_len + 64);
char scramble_buf[SCRAMBLE_LENGTH];
char *end= buff;
@@ -11321,7 +11320,7 @@ static bool send_server_handshake_packet(MPVIO_EXT *mpvio,
}
end= strxnmov(end, SERVER_VERSION_LENGTH, RPL_VERSION_HACK, server_version, NullS) + 1;
- int4store((uchar*) end, mpvio->thd->thread_id);
+ int4store((uchar*) end, mpvio->auth_info.thd->thread_id);
end+= 4;
/*
@@ -11336,7 +11335,7 @@ static bool send_server_handshake_packet(MPVIO_EXT *mpvio,
int2store(end, thd->client_capabilities);
/* write server characteristics: up to 16 bytes allowed */
end[2]= (char) default_charset_info->number;
- int2store(end+3, mpvio->thd->server_status);
+ int2store(end+3, mpvio->auth_info.thd->server_status);
int2store(end+5, thd->client_capabilities >> 16);
end[7]= data_len;
DBUG_EXECUTE_IF("poison_srv_handshake_scramble_len", end[7]= -100;);
@@ -11349,9 +11348,9 @@ static bool send_server_handshake_packet(MPVIO_EXT *mpvio,
end= strmake(end, plugin_name(mpvio->plugin)->str,
plugin_name(mpvio->plugin)->length);
- int res= my_net_write(&mpvio->thd->net, (uchar*) buff,
+ int res= my_net_write(&mpvio->auth_info.thd->net, (uchar*) buff,
(size_t) (end - buff + 1)) ||
- net_flush(&mpvio->thd->net);
+ net_flush(&mpvio->auth_info.thd->net);
my_afree(buff);
DBUG_RETURN (res);
}
@@ -11410,7 +11409,7 @@ static bool send_plugin_request_packet(MPVIO_EXT *mpvio,
{
DBUG_ASSERT(mpvio->packets_written == 1);
DBUG_ASSERT(mpvio->packets_read == 1);
- NET *net= &mpvio->thd->net;
+ NET *net= &mpvio->auth_info.thd->net;
static uchar switch_plugin_request_buf[]= { 254 };
DBUG_ENTER("send_plugin_request_packet");
@@ -11435,7 +11434,7 @@ static bool send_plugin_request_packet(MPVIO_EXT *mpvio,
client_auth_plugin == old_password_plugin_name.str;
if (switch_from_long_to_short_scramble)
- DBUG_RETURN (secure_auth(mpvio->thd) ||
+ DBUG_RETURN (secure_auth(mpvio->auth_info.thd) ||
my_net_write(net, switch_plugin_request_buf, 1) ||
net_flush(net));
@@ -11451,8 +11450,8 @@ static bool send_plugin_request_packet(MPVIO_EXT *mpvio,
if (switch_from_short_to_long_scramble)
{
my_error(ER_NOT_SUPPORTED_AUTH_MODE, MYF(0));
- general_log_print(mpvio->thd, COM_CONNECT,
- ER_THD(mpvio->thd, ER_NOT_SUPPORTED_AUTH_MODE));
+ general_log_print(mpvio->auth_info.thd, COM_CONNECT,
+ ER_THD(mpvio->auth_info.thd, ER_NOT_SUPPORTED_AUTH_MODE));
DBUG_RETURN (1);
}
@@ -11476,7 +11475,7 @@ static bool send_plugin_request_packet(MPVIO_EXT *mpvio,
*/
static bool find_mpvio_user(MPVIO_EXT *mpvio)
{
- Security_context *sctx= mpvio->thd->security_ctx;
+ Security_context *sctx= mpvio->auth_info.thd->security_ctx;
DBUG_ENTER("find_mpvio_user");
DBUG_ASSERT(mpvio->acl_user == 0);
@@ -11484,7 +11483,7 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio)
ACL_USER *user= find_user_or_anon(sctx->host, sctx->user, sctx->ip);
if (user)
- mpvio->acl_user= user->copy(mpvio->thd->mem_root);
+ mpvio->acl_user= user->copy(mpvio->auth_info.thd->mem_root);
mysql_mutex_unlock(&acl_cache->lock);
@@ -11508,12 +11507,12 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio)
if (!acl_users.elements)
{
mysql_mutex_unlock(&acl_cache->lock);
- login_failed_error(mpvio->thd);
+ login_failed_error(mpvio->auth_info.thd);
DBUG_RETURN(1);
}
uint i= nr1 % acl_users.elements;
ACL_USER *acl_user_tmp= dynamic_element(&acl_users, i, ACL_USER*);
- mpvio->acl_user= acl_user_tmp->copy(mpvio->thd->mem_root);
+ mpvio->acl_user= acl_user_tmp->copy(mpvio->auth_info.thd->mem_root);
mysql_mutex_unlock(&acl_cache->lock);
mpvio->make_it_fail= true;
@@ -11522,15 +11521,15 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio)
/* user account requires non-default plugin and the client is too old */
if (mpvio->acl_user->plugin.str != native_password_plugin_name.str &&
mpvio->acl_user->plugin.str != old_password_plugin_name.str &&
- !(mpvio->thd->client_capabilities & CLIENT_PLUGIN_AUTH))
+ !(mpvio->auth_info.thd->client_capabilities & CLIENT_PLUGIN_AUTH))
{
DBUG_ASSERT(my_strcasecmp(system_charset_info, mpvio->acl_user->plugin.str,
native_password_plugin_name.str));
DBUG_ASSERT(my_strcasecmp(system_charset_info, mpvio->acl_user->plugin.str,
old_password_plugin_name.str));
my_error(ER_NOT_SUPPORTED_AUTH_MODE, MYF(0));
- general_log_print(mpvio->thd, COM_CONNECT,
- ER_THD(mpvio->thd, ER_NOT_SUPPORTED_AUTH_MODE));
+ general_log_print(mpvio->auth_info.thd, COM_CONNECT,
+ ER_THD(mpvio->auth_info.thd, ER_NOT_SUPPORTED_AUTH_MODE));
DBUG_RETURN (1);
}
@@ -11587,7 +11586,7 @@ read_client_connect_attrs(char **ptr, char *end, CHARSET_INFO *from_cs)
/* the packet format is described in send_change_user_packet() */
static bool parse_com_change_user_packet(MPVIO_EXT *mpvio, uint packet_length)
{
- THD *thd= mpvio->thd;
+ THD *thd= mpvio->auth_info.thd;
NET *net= &thd->net;
Security_context *sctx= thd->security_ctx;
@@ -11742,7 +11741,7 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
uchar **buff, ulong pkt_len)
{
#ifndef EMBEDDED_LIBRARY
- THD *thd= mpvio->thd;
+ THD *thd= mpvio->auth_info.thd;
NET *net= &thd->net;
char *end;
DBUG_ASSERT(mpvio->status == MPVIO_EXT::FAILURE);
@@ -11951,7 +11950,7 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
if ((thd->client_capabilities & CLIENT_CONNECT_ATTRS) &&
read_client_connect_attrs(&next_field, ((char *)net->read_pos) + pkt_len,
- mpvio->thd->charset()))
+ mpvio->auth_info.thd->charset()))
return packet_error;
/*
@@ -12036,13 +12035,13 @@ static int server_mpvio_write_packet(MYSQL_PLUGIN_VIO *param,
We'll escape these bytes with \1. Consequently, we
have to escape \1 byte too.
*/
- res= net_write_command(&mpvio->thd->net, 1, (uchar*)"", 0,
+ res= net_write_command(&mpvio->auth_info.thd->net, 1, (uchar*)"", 0,
packet, packet_len);
}
else
{
- res= my_net_write(&mpvio->thd->net, packet, packet_len) ||
- net_flush(&mpvio->thd->net);
+ res= my_net_write(&mpvio->auth_info.thd->net, packet, packet_len) ||
+ net_flush(&mpvio->auth_info.thd->net);
}
mpvio->packets_written++;
DBUG_RETURN(res);
@@ -12072,7 +12071,7 @@ static int server_mpvio_read_packet(MYSQL_PLUGIN_VIO *param, uchar **buf)
if (server_mpvio_write_packet(mpvio, 0, 0))
pkt_len= packet_error;
else
- pkt_len= my_net_read(&mpvio->thd->net);
+ pkt_len= my_net_read(&mpvio->auth_info.thd->net);
}
else if (mpvio->cached_client_reply.pkt)
{
@@ -12106,10 +12105,10 @@ static int server_mpvio_read_packet(MYSQL_PLUGIN_VIO *param, uchar **buf)
if (server_mpvio_write_packet(mpvio, 0, 0))
pkt_len= packet_error;
else
- pkt_len= my_net_read(&mpvio->thd->net);
+ pkt_len= my_net_read(&mpvio->auth_info.thd->net);
}
else
- pkt_len= my_net_read(&mpvio->thd->net);
+ pkt_len= my_net_read(&mpvio->auth_info.thd->net);
if (pkt_len == packet_error)
goto err;
@@ -12127,14 +12126,14 @@ static int server_mpvio_read_packet(MYSQL_PLUGIN_VIO *param, uchar **buf)
goto err;
}
else
- *buf= mpvio->thd->net.read_pos;
+ *buf= mpvio->auth_info.thd->net.read_pos;
DBUG_RETURN((int)pkt_len);
err:
if (mpvio->status == MPVIO_EXT::FAILURE)
{
- if (!mpvio->thd->is_error())
+ if (!mpvio->auth_info.thd->is_error())
my_error(ER_HANDSHAKE_ERROR, MYF(0));
}
DBUG_RETURN(-1);
@@ -12148,7 +12147,7 @@ static void server_mpvio_info(MYSQL_PLUGIN_VIO *vio,
MYSQL_PLUGIN_VIO_INFO *info)
{
MPVIO_EXT *mpvio= (MPVIO_EXT *) vio;
- mpvio_info(mpvio->thd->net.vio, info);
+ mpvio_info(mpvio->auth_info.thd->net.vio, info);
}
static bool acl_check_ssl(THD *thd, const ACL_USER *acl_user)
@@ -12283,11 +12282,11 @@ static int do_auth_once(THD *thd, const LEX_STRING *auth_plugin_name,
if (plugin)
{
st_mysql_auth *auth= (st_mysql_auth *) plugin_decl(plugin)->info;
- switch (auth->interface_version) {
- case 0x0200:
+ switch (auth->interface_version >> 8) {
+ case 0x02:
res= auth->authenticate_user(mpvio, &mpvio->auth_info);
break;
- case 0x0100:
+ case 0x01:
{
MYSQL_SERVER_AUTH_INFO_0x0100 compat;
compat.downgrade(&mpvio->auth_info);
@@ -12306,7 +12305,7 @@ static int do_auth_once(THD *thd, const LEX_STRING *auth_plugin_name,
/* Server cannot load the required plugin. */
Host_errors errors;
errors.m_no_auth_plugin= 1;
- inc_host_errors(mpvio->thd->security_ctx->ip, &errors);
+ inc_host_errors(mpvio->auth_info.thd->security_ctx->ip, &errors);
my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), auth_plugin_name->str);
res= CR_ERROR;
}
@@ -12351,9 +12350,9 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len)
mpvio.read_packet= server_mpvio_read_packet;
mpvio.write_packet= server_mpvio_write_packet;
mpvio.info= server_mpvio_info;
- mpvio.thd= thd;
mpvio.status= MPVIO_EXT::FAILURE;
mpvio.make_it_fail= false;
+ mpvio.auth_info.thd= thd;
mpvio.auth_info.host_or_ip= thd->security_ctx->host_or_ip;
mpvio.auth_info.host_or_ip_length=
(unsigned int) strlen(thd->security_ctx->host_or_ip);
@@ -12452,7 +12451,7 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len)
errors.m_auth_plugin= 1;
break;
}
- inc_host_errors(mpvio.thd->security_ctx->ip, &errors);
+ inc_host_errors(mpvio.auth_info.thd->security_ctx->ip, &errors);
if (!thd->is_error())
login_failed_error(thd);
DBUG_RETURN(1);
@@ -12479,7 +12478,7 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len)
{
Host_errors errors;
errors.m_proxy_user= 1;
- inc_host_errors(mpvio.thd->security_ctx->ip, &errors);
+ inc_host_errors(mpvio.auth_info.thd->security_ctx->ip, &errors);
if (!thd->is_error())
login_failed_error(thd);
DBUG_RETURN(1);
@@ -12499,7 +12498,7 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len)
Host_errors errors;
errors.m_proxy_user_acl= 1;
- inc_host_errors(mpvio.thd->security_ctx->ip, &errors);
+ inc_host_errors(mpvio.auth_info.thd->security_ctx->ip, &errors);
if (!thd->is_error())
login_failed_error(thd);
DBUG_RETURN(1);
@@ -12529,7 +12528,7 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len)
{
Host_errors errors;
errors.m_ssl= 1;
- inc_host_errors(mpvio.thd->security_ctx->ip, &errors);
+ inc_host_errors(mpvio.auth_info.thd->security_ctx->ip, &errors);
login_failed_error(thd);
DBUG_RETURN(1);
}
@@ -12666,7 +12665,7 @@ static int native_password_authenticate(MYSQL_PLUGIN_VIO *vio,
uchar *pkt;
int pkt_len;
MPVIO_EXT *mpvio= (MPVIO_EXT *) vio;
- THD *thd=mpvio->thd;
+ THD *thd=info->thd;
DBUG_ENTER("native_password_authenticate");
/* generate the scramble, or reuse the old one */
@@ -12751,7 +12750,7 @@ static int old_password_authenticate(MYSQL_PLUGIN_VIO *vio,
uchar *pkt;
int pkt_len;
MPVIO_EXT *mpvio= (MPVIO_EXT *) vio;
- THD *thd=mpvio->thd;
+ THD *thd=info->thd;
/* generate the scramble, or reuse the old one */
if (thd->scramble[SCRAMBLE_LENGTH])
From 0877eff4012ab1184112814a3492d23bf266f848 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Mon, 6 Mar 2017 19:34:22 +0100
Subject: [PATCH 184/226] thd_rnd service
---
include/mysql/plugin_audit.h.pp | 6 ++
include/mysql/plugin_auth.h.pp | 6 ++
include/mysql/plugin_encryption.h.pp | 6 ++
include/mysql/plugin_ftparser.h.pp | 6 ++
include/mysql/plugin_password_validation.h.pp | 6 ++
include/mysql/service_thd_rnd.h | 62 +++++++++++++++++++
include/mysql/services.h | 1 +
include/service_versions.h | 1 +
libservices/CMakeLists.txt | 1 +
libservices/thd_rnd_service.c | 17 +++++
sql/password.c | 6 +-
sql/sql_acl.cc | 6 +-
sql/sql_class.cc | 22 +++++++
sql/sql_plugin_services.ic | 6 ++
14 files changed, 148 insertions(+), 4 deletions(-)
create mode 100644 include/mysql/service_thd_rnd.h
create mode 100644 libservices/thd_rnd_service.c
diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp
index 309bae1a0b0c2..c74fa4bacb7cf 100644
--- a/include/mysql/plugin_audit.h.pp
+++ b/include/mysql/plugin_audit.h.pp
@@ -219,6 +219,12 @@
} *thd_autoinc_service;
void thd_get_autoinc(const void* thd,
unsigned long* off, unsigned long* inc);
+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);
+} *thd_rnd_service;
+double thd_rnd(void* thd);
+void thd_create_random_password(void* thd, char *to, size_t length);
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);
diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp
index 63ad776314d51..c3e90210dd65d 100644
--- a/include/mysql/plugin_auth.h.pp
+++ b/include/mysql/plugin_auth.h.pp
@@ -219,6 +219,12 @@
} *thd_autoinc_service;
void thd_get_autoinc(const void* thd,
unsigned long* off, unsigned long* inc);
+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);
+} *thd_rnd_service;
+double thd_rnd(void* thd);
+void thd_create_random_password(void* thd, char *to, size_t length);
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);
diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp
index 86d4427bc036d..3d027e5838983 100644
--- a/include/mysql/plugin_encryption.h.pp
+++ b/include/mysql/plugin_encryption.h.pp
@@ -219,6 +219,12 @@
} *thd_autoinc_service;
void thd_get_autoinc(const void* thd,
unsigned long* off, unsigned long* inc);
+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);
+} *thd_rnd_service;
+double thd_rnd(void* thd);
+void thd_create_random_password(void* thd, char *to, size_t length);
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);
diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp
index 595735f0cf58b..44ac17fbc7b37 100644
--- a/include/mysql/plugin_ftparser.h.pp
+++ b/include/mysql/plugin_ftparser.h.pp
@@ -219,6 +219,12 @@
} *thd_autoinc_service;
void thd_get_autoinc(const void* thd,
unsigned long* off, unsigned long* inc);
+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);
+} *thd_rnd_service;
+double thd_rnd(void* thd);
+void thd_create_random_password(void* thd, char *to, size_t length);
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);
diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp
index 23a56273e5104..8851ae77b4a94 100644
--- a/include/mysql/plugin_password_validation.h.pp
+++ b/include/mysql/plugin_password_validation.h.pp
@@ -219,6 +219,12 @@
} *thd_autoinc_service;
void thd_get_autoinc(const void* thd,
unsigned long* off, unsigned long* inc);
+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);
+} *thd_rnd_service;
+double thd_rnd(void* thd);
+void thd_create_random_password(void* thd, char *to, size_t length);
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);
diff --git a/include/mysql/service_thd_rnd.h b/include/mysql/service_thd_rnd.h
new file mode 100644
index 0000000000000..21133c7889ff6
--- /dev/null
+++ b/include/mysql/service_thd_rnd.h
@@ -0,0 +1,62 @@
+#ifndef MYSQL_SERVICE_THD_RND_INCLUDED
+/* Copyright (C) 2017 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-1301 USA */
+
+/**
+ @file
+ This service provides access to the thd-local random number generator.
+
+ It's preferrable over the global one, because concurrent threads
+ can generate random numbers without fighting each other over the access
+ to the shared rnd state.
+*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef MYSQL_ABI_CHECK
+#include
+#endif
+
+extern struct thd_rnd_service_st {
+ double (*thd_rnd_ptr)(MYSQL_THD thd);
+ void (*thd_c_r_p_ptr)(MYSQL_THD thd, char *to, size_t length);
+} *thd_rnd_service;
+
+#ifdef MYSQL_DYNAMIC_PLUGIN
+#define thd_rnd(A) thd_rnd_service->thd_rnd_ptr(A)
+#define thd_create_random_password(A,B,C) thd_rnd_service->thd_c_r_p_ptr(A,B,C)
+#else
+
+double thd_rnd(MYSQL_THD thd);
+
+/**
+ Generate string of printable random characters of requested length.
+
+ @param to[out] Buffer for generation; must be at least length+1 bytes
+ long; result string is always null-terminated
+ @param length[in] How many random characters to put in buffer
+*/
+void thd_create_random_password(MYSQL_THD thd, char *to, size_t length);
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#define MYSQL_SERVICE_THD_RND_INCLUDED
+#endif
diff --git a/include/mysql/services.h b/include/mysql/services.h
index 3ba0ce6511c8e..6cb5f50dc8208 100644
--- a/include/mysql/services.h
+++ b/include/mysql/services.h
@@ -32,6 +32,7 @@ extern "C" {
#include
#include
#include
+#include
#include
#include
#include
diff --git a/include/service_versions.h b/include/service_versions.h
index f78697d277c29..a083179264391 100644
--- a/include/service_versions.h
+++ b/include/service_versions.h
@@ -34,6 +34,7 @@
#define VERSION_wsrep 0x0201
#define VERSION_logger 0x0100
#define VERSION_base64 0x0100
+#define VERSION_thd_rnd 0x0100
#define VERSION_thd_autoinc 0x0100
#define VERSION_thd_error_context 0x0100
#define VERSION_thd_specifics 0x0100
diff --git a/libservices/CMakeLists.txt b/libservices/CMakeLists.txt
index 04f3cb4b69b04..5c789885b50a2 100644
--- a/libservices/CMakeLists.txt
+++ b/libservices/CMakeLists.txt
@@ -22,6 +22,7 @@ SET(MYSQLSERVICES_SOURCES
thd_timezone_service.c
thd_autoinc_service.c
thd_error_context_service.c
+ thd_rnd_service.c
thd_specifics_service.c
progress_report_service.c
debug_sync_service.c
diff --git a/libservices/thd_rnd_service.c b/libservices/thd_rnd_service.c
new file mode 100644
index 0000000000000..fbba611a8ff4f
--- /dev/null
+++ b/libservices/thd_rnd_service.c
@@ -0,0 +1,17 @@
+/* Copyright (C) 2017 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-1301 USA */
+
+#include
+SERVICE_VERSION thd_rnd_service= (void *) VERSION_thd_rnd;
diff --git a/sql/password.c b/sql/password.c
index 8d05f7d237524..02e4a0c37c794 100644
--- a/sql/password.c
+++ b/sql/password.c
@@ -38,7 +38,7 @@
The new authentication is performed in following manner:
- SERVER: public_seed=create_random_string()
+ SERVER: public_seed=thd_create_random_password()
send(public_seed)
CLIENT: recv(public_seed)
@@ -278,6 +278,7 @@ void make_password_from_salt_323(char *to, const ulong *salt)
**************** MySQL 4.1.1 authentication routines *************
*/
+#if MYSQL_VERSION_ID < 0x100200
/**
Generate string of printable random characters of requested length.
@@ -296,6 +297,9 @@ void create_random_string(char *to, uint length,
*to= (char) (my_rnd(rand_st)*94+33);
*to= '\0';
}
+#else
+#error
+#endif
/* Character to use as version identifier for version 4.1 */
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 142e2ecc198ba..8376d5cc767a9 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -11313,7 +11313,7 @@ static bool send_server_handshake_packet(MPVIO_EXT *mpvio,
native_password_plugin will have to send it in a separate packet,
adding one more round trip.
*/
- create_random_string(thd->scramble, SCRAMBLE_LENGTH, &thd->rand);
+ thd_create_random_password(thd, thd->scramble, SCRAMBLE_LENGTH);
data= thd->scramble;
}
data_len= SCRAMBLE_LENGTH;
@@ -12671,7 +12671,7 @@ static int native_password_authenticate(MYSQL_PLUGIN_VIO *vio,
/* generate the scramble, or reuse the old one */
if (thd->scramble[SCRAMBLE_LENGTH])
{
- create_random_string(thd->scramble, SCRAMBLE_LENGTH, &thd->rand);
+ thd_create_random_password(thd, thd->scramble, SCRAMBLE_LENGTH);
/* and send it to the client */
if (mpvio->write_packet(mpvio, (uchar*)thd->scramble, SCRAMBLE_LENGTH + 1))
DBUG_RETURN(CR_AUTH_HANDSHAKE);
@@ -12755,7 +12755,7 @@ static int old_password_authenticate(MYSQL_PLUGIN_VIO *vio,
/* generate the scramble, or reuse the old one */
if (thd->scramble[SCRAMBLE_LENGTH])
{
- create_random_string(thd->scramble, SCRAMBLE_LENGTH, &thd->rand);
+ thd_create_random_password(thd, thd->scramble, SCRAMBLE_LENGTH);
/* and send it to the client */
if (mpvio->write_packet(mpvio, (uchar*)thd->scramble, SCRAMBLE_LENGTH + 1))
return CR_AUTH_HANDSHAKE;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index fb58519b81611..3a7e501c6c2fa 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -4475,6 +4475,28 @@ extern "C" int thd_is_connected(MYSQL_THD thd)
}
+extern "C" double thd_rnd(MYSQL_THD thd)
+{
+ return my_rnd(&thd->rand);
+}
+
+
+/**
+ Generate string of printable random characters of requested length.
+
+ @param to[out] Buffer for generation; must be at least length+1 bytes
+ long; result string is always null-terminated
+ @param length[in] How many random characters to put in buffer
+*/
+extern "C" void thd_create_random_password(MYSQL_THD thd,
+ char *to, size_t length)
+{
+ for (char *end= to + length; to < end; to++)
+ *to= (char) (my_rnd(&thd->rand)*94 + 33);
+ *to= '\0';
+}
+
+
#ifdef INNODB_COMPATIBILITY_HOOKS
extern "C" const struct charset_info_st *thd_charset(MYSQL_THD thd)
{
diff --git a/sql/sql_plugin_services.ic b/sql/sql_plugin_services.ic
index e08870e9f985a..564276a852a48 100644
--- a/sql/sql_plugin_services.ic
+++ b/sql/sql_plugin_services.ic
@@ -119,6 +119,11 @@ static struct thd_autoinc_service_st thd_autoinc_handler= {
thd_get_autoinc
};
+static struct thd_rnd_service_st thd_rnd_handler= {
+ thd_rnd,
+ thd_create_random_password
+};
+
static struct base64_service_st base64_handler= {
base64_needed_encoded_length,
base64_encode_max_arg_length,
@@ -205,6 +210,7 @@ static struct st_service_ref list_of_services[]=
{ "my_md5_service", VERSION_my_md5, &my_md5_handler},
{ "logger_service", VERSION_logger, &logger_service_handler },
{ "base64_service", VERSION_base64, &base64_handler },
+ { "thd_rnd_service", VERSION_thd_rnd, &thd_rnd_handler },
{ "thd_autoinc_service", VERSION_thd_autoinc, &thd_autoinc_handler },
{ "wsrep_service", VERSION_wsrep, &wsrep_handler },
{ "encryption_service", VERSION_encryption, &encryption_handler },
From 227f63db3b0b9a1ce29c37f1c104ba5d204d0392 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Mon, 6 Mar 2017 19:37:48 +0100
Subject: [PATCH 185/226] cleanup: sort various lists of services
---
include/mysql/plugin_audit.h.pp | 434 +++++++++---------
include/mysql/plugin_auth.h.pp | 434 +++++++++---------
include/mysql/plugin_encryption.h.pp | 434 +++++++++---------
include/mysql/plugin_ftparser.h.pp | 434 +++++++++---------
include/mysql/plugin_password_validation.h.pp | 434 +++++++++---------
include/mysql/services.h | 24 +-
include/service_versions.h | 25 +-
libservices/CMakeLists.txt | 25 +-
sql/sql_plugin.cc | 4 +-
sql/sql_plugin_services.ic | 28 +-
10 files changed, 1138 insertions(+), 1138 deletions(-)
diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp
index c74fa4bacb7cf..eb5369c0377e0 100644
--- a/include/mysql/plugin_audit.h.pp
+++ b/include/mysql/plugin_audit.h.pp
@@ -1,54 +1,148 @@
typedef char my_bool;
typedef void * MYSQL_PLUGIN;
+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 base64_needed_encoded_length(int length_of_data);
+int base64_encode_max_arg_length(void);
+int base64_needed_decoded_length(int length_of_encoded_data);
+int base64_decode_max_arg_length();
+int base64_encode(const void *src, size_t src_len, char *dst);
+int 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);
+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;
+}
+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);
+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*);
+} *thd_kill_statement_service;
+enum thd_kill_levels thd_kill_level(const void*);
+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 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 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);
-struct st_mysql_lex_string
-{
- char *str;
- size_t length;
-};
-typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
-extern struct thd_alloc_service_st {
- void *(*thd_alloc_func)(void*, unsigned int);
- void *(*thd_calloc_func)(void*, unsigned int);
- char *(*thd_strdup_func)(void*, const char *);
- char *(*thd_strmake_func)(void*, const char *, unsigned int);
- void *(*thd_memdup_func)(void*, const void*, unsigned int);
- MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
- const char *, unsigned int, int);
-} *thd_alloc_service;
-void *thd_alloc(void* thd, unsigned int size);
-void *thd_calloc(void* thd, unsigned int size);
-char *thd_strdup(void* thd, const char *str);
-char *thd_strmake(void* thd, const char *str, unsigned int size);
-void *thd_memdup(void* thd, const void* str, unsigned int size);
-MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
- const char *str, unsigned int size,
- int allocate_lex_string);
-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)(void*, int);
- void (*thd_wait_end_func)(void*);
-} *thd_wait_service;
-void thd_wait_begin(void* thd, int wait_type);
-void thd_wait_end(void* thd);
extern struct progress_report_service_st {
void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
void (*thd_progress_report_func)(void* thd,
@@ -69,35 +163,20 @@
void thd_progress_end(void* thd);
const char *set_thd_proc_info(void*, const char * info, const char *func,
const char *file, unsigned int line);
-extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
-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*);
-} *thd_kill_statement_service;
-enum thd_kill_levels thd_kill_level(const void*);
-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 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);
-} *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);
+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 struct my_sha2_service_st {
void (*my_sha224_type)(unsigned char*, const char*, size_t);
void (*my_sha224_multi_type)(unsigned char*, ...);
@@ -148,83 +227,35 @@
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 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 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 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 base64_needed_encoded_length(int length_of_data);
-int base64_encode_max_arg_length(void);
-int base64_needed_decoded_length(int length_of_encoded_data);
-int base64_decode_max_arg_length();
-int base64_encode(const void *src, size_t src_len, char *dst);
-int base64_decode(const char *src, size_t src_len,
- void *dst, const char **end_ptr, int flags);
-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);
+struct st_mysql_lex_string
+{
+ char *str;
+ size_t length;
+};
+typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+extern struct thd_alloc_service_st {
+ void *(*thd_alloc_func)(void*, unsigned int);
+ void *(*thd_calloc_func)(void*, unsigned int);
+ char *(*thd_strdup_func)(void*, const char *);
+ char *(*thd_strmake_func)(void*, const char *, unsigned int);
+ void *(*thd_memdup_func)(void*, const void*, unsigned int);
+ MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
+ const char *, unsigned int, int);
+} *thd_alloc_service;
+void *thd_alloc(void* thd, unsigned int size);
+void *thd_calloc(void* thd, unsigned int size);
+char *thd_strdup(void* thd, const char *str);
+char *thd_strmake(void* thd, const char *str, unsigned int size);
+void *thd_memdup(void* thd, const void* str, unsigned int size);
+MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
+ const char *str, unsigned int size,
+ int allocate_lex_string);
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc);
} *thd_autoinc_service;
void thd_get_autoinc(const void* thd,
unsigned long* off, unsigned long* inc);
-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);
-} *thd_rnd_service;
-double thd_rnd(void* thd);
-void thd_create_random_password(void* thd, char *to, size_t length);
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);
@@ -242,6 +273,12 @@
char *thd_get_error_context_description(void* thd,
char *buffer, unsigned int length,
unsigned int max_query_length);
+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);
+} *thd_rnd_service;
+double thd_rnd(void* thd);
+void thd_create_random_password(void* thd, char *to, size_t length);
typedef int MYSQL_THD_KEY_T;
extern struct thd_specifics_service_st {
int (*thd_key_create_func)(MYSQL_THD_KEY_T *key);
@@ -253,82 +290,45 @@
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);
-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)
+typedef long my_time_t;
+enum enum_mysql_timestamp_type
{
- 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;
-}
-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);
+ MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
+ MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
};
-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);
+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 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);
+} *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);
+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)(void*, int);
+ void (*thd_wait_end_func)(void*);
+} *thd_wait_service;
+void thd_wait_begin(void* thd, int wait_type);
+void thd_wait_end(void* thd);
struct st_mysql_xid {
long formatID;
long gtrid_length;
diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp
index c3e90210dd65d..766682fb44fcc 100644
--- a/include/mysql/plugin_auth.h.pp
+++ b/include/mysql/plugin_auth.h.pp
@@ -1,54 +1,148 @@
typedef char my_bool;
typedef void * MYSQL_PLUGIN;
+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 base64_needed_encoded_length(int length_of_data);
+int base64_encode_max_arg_length(void);
+int base64_needed_decoded_length(int length_of_encoded_data);
+int base64_decode_max_arg_length();
+int base64_encode(const void *src, size_t src_len, char *dst);
+int 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);
+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;
+}
+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);
+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*);
+} *thd_kill_statement_service;
+enum thd_kill_levels thd_kill_level(const void*);
+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 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 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);
-struct st_mysql_lex_string
-{
- char *str;
- size_t length;
-};
-typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
-extern struct thd_alloc_service_st {
- void *(*thd_alloc_func)(void*, unsigned int);
- void *(*thd_calloc_func)(void*, unsigned int);
- char *(*thd_strdup_func)(void*, const char *);
- char *(*thd_strmake_func)(void*, const char *, unsigned int);
- void *(*thd_memdup_func)(void*, const void*, unsigned int);
- MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
- const char *, unsigned int, int);
-} *thd_alloc_service;
-void *thd_alloc(void* thd, unsigned int size);
-void *thd_calloc(void* thd, unsigned int size);
-char *thd_strdup(void* thd, const char *str);
-char *thd_strmake(void* thd, const char *str, unsigned int size);
-void *thd_memdup(void* thd, const void* str, unsigned int size);
-MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
- const char *str, unsigned int size,
- int allocate_lex_string);
-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)(void*, int);
- void (*thd_wait_end_func)(void*);
-} *thd_wait_service;
-void thd_wait_begin(void* thd, int wait_type);
-void thd_wait_end(void* thd);
extern struct progress_report_service_st {
void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
void (*thd_progress_report_func)(void* thd,
@@ -69,35 +163,20 @@
void thd_progress_end(void* thd);
const char *set_thd_proc_info(void*, const char * info, const char *func,
const char *file, unsigned int line);
-extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
-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*);
-} *thd_kill_statement_service;
-enum thd_kill_levels thd_kill_level(const void*);
-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 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);
-} *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);
+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 struct my_sha2_service_st {
void (*my_sha224_type)(unsigned char*, const char*, size_t);
void (*my_sha224_multi_type)(unsigned char*, ...);
@@ -148,83 +227,35 @@
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 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 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 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 base64_needed_encoded_length(int length_of_data);
-int base64_encode_max_arg_length(void);
-int base64_needed_decoded_length(int length_of_encoded_data);
-int base64_decode_max_arg_length();
-int base64_encode(const void *src, size_t src_len, char *dst);
-int base64_decode(const char *src, size_t src_len,
- void *dst, const char **end_ptr, int flags);
-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);
+struct st_mysql_lex_string
+{
+ char *str;
+ size_t length;
+};
+typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+extern struct thd_alloc_service_st {
+ void *(*thd_alloc_func)(void*, unsigned int);
+ void *(*thd_calloc_func)(void*, unsigned int);
+ char *(*thd_strdup_func)(void*, const char *);
+ char *(*thd_strmake_func)(void*, const char *, unsigned int);
+ void *(*thd_memdup_func)(void*, const void*, unsigned int);
+ MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
+ const char *, unsigned int, int);
+} *thd_alloc_service;
+void *thd_alloc(void* thd, unsigned int size);
+void *thd_calloc(void* thd, unsigned int size);
+char *thd_strdup(void* thd, const char *str);
+char *thd_strmake(void* thd, const char *str, unsigned int size);
+void *thd_memdup(void* thd, const void* str, unsigned int size);
+MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
+ const char *str, unsigned int size,
+ int allocate_lex_string);
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc);
} *thd_autoinc_service;
void thd_get_autoinc(const void* thd,
unsigned long* off, unsigned long* inc);
-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);
-} *thd_rnd_service;
-double thd_rnd(void* thd);
-void thd_create_random_password(void* thd, char *to, size_t length);
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);
@@ -242,6 +273,12 @@
char *thd_get_error_context_description(void* thd,
char *buffer, unsigned int length,
unsigned int max_query_length);
+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);
+} *thd_rnd_service;
+double thd_rnd(void* thd);
+void thd_create_random_password(void* thd, char *to, size_t length);
typedef int MYSQL_THD_KEY_T;
extern struct thd_specifics_service_st {
int (*thd_key_create_func)(MYSQL_THD_KEY_T *key);
@@ -253,82 +290,45 @@
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);
-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)
+typedef long my_time_t;
+enum enum_mysql_timestamp_type
{
- 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;
-}
-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);
+ MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
+ MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
};
-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);
+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 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);
+} *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);
+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)(void*, int);
+ void (*thd_wait_end_func)(void*);
+} *thd_wait_service;
+void thd_wait_begin(void* thd, int wait_type);
+void thd_wait_end(void* thd);
struct st_mysql_xid {
long formatID;
long gtrid_length;
diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp
index 3d027e5838983..6a66e90234aa7 100644
--- a/include/mysql/plugin_encryption.h.pp
+++ b/include/mysql/plugin_encryption.h.pp
@@ -1,54 +1,148 @@
typedef char my_bool;
typedef void * MYSQL_PLUGIN;
+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 base64_needed_encoded_length(int length_of_data);
+int base64_encode_max_arg_length(void);
+int base64_needed_decoded_length(int length_of_encoded_data);
+int base64_decode_max_arg_length();
+int base64_encode(const void *src, size_t src_len, char *dst);
+int 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);
+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;
+}
+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);
+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*);
+} *thd_kill_statement_service;
+enum thd_kill_levels thd_kill_level(const void*);
+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 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 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);
-struct st_mysql_lex_string
-{
- char *str;
- size_t length;
-};
-typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
-extern struct thd_alloc_service_st {
- void *(*thd_alloc_func)(void*, unsigned int);
- void *(*thd_calloc_func)(void*, unsigned int);
- char *(*thd_strdup_func)(void*, const char *);
- char *(*thd_strmake_func)(void*, const char *, unsigned int);
- void *(*thd_memdup_func)(void*, const void*, unsigned int);
- MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
- const char *, unsigned int, int);
-} *thd_alloc_service;
-void *thd_alloc(void* thd, unsigned int size);
-void *thd_calloc(void* thd, unsigned int size);
-char *thd_strdup(void* thd, const char *str);
-char *thd_strmake(void* thd, const char *str, unsigned int size);
-void *thd_memdup(void* thd, const void* str, unsigned int size);
-MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
- const char *str, unsigned int size,
- int allocate_lex_string);
-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)(void*, int);
- void (*thd_wait_end_func)(void*);
-} *thd_wait_service;
-void thd_wait_begin(void* thd, int wait_type);
-void thd_wait_end(void* thd);
extern struct progress_report_service_st {
void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
void (*thd_progress_report_func)(void* thd,
@@ -69,35 +163,20 @@
void thd_progress_end(void* thd);
const char *set_thd_proc_info(void*, const char * info, const char *func,
const char *file, unsigned int line);
-extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
-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*);
-} *thd_kill_statement_service;
-enum thd_kill_levels thd_kill_level(const void*);
-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 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);
-} *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);
+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 struct my_sha2_service_st {
void (*my_sha224_type)(unsigned char*, const char*, size_t);
void (*my_sha224_multi_type)(unsigned char*, ...);
@@ -148,83 +227,35 @@
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 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 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 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 base64_needed_encoded_length(int length_of_data);
-int base64_encode_max_arg_length(void);
-int base64_needed_decoded_length(int length_of_encoded_data);
-int base64_decode_max_arg_length();
-int base64_encode(const void *src, size_t src_len, char *dst);
-int base64_decode(const char *src, size_t src_len,
- void *dst, const char **end_ptr, int flags);
-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);
+struct st_mysql_lex_string
+{
+ char *str;
+ size_t length;
+};
+typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+extern struct thd_alloc_service_st {
+ void *(*thd_alloc_func)(void*, unsigned int);
+ void *(*thd_calloc_func)(void*, unsigned int);
+ char *(*thd_strdup_func)(void*, const char *);
+ char *(*thd_strmake_func)(void*, const char *, unsigned int);
+ void *(*thd_memdup_func)(void*, const void*, unsigned int);
+ MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
+ const char *, unsigned int, int);
+} *thd_alloc_service;
+void *thd_alloc(void* thd, unsigned int size);
+void *thd_calloc(void* thd, unsigned int size);
+char *thd_strdup(void* thd, const char *str);
+char *thd_strmake(void* thd, const char *str, unsigned int size);
+void *thd_memdup(void* thd, const void* str, unsigned int size);
+MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
+ const char *str, unsigned int size,
+ int allocate_lex_string);
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc);
} *thd_autoinc_service;
void thd_get_autoinc(const void* thd,
unsigned long* off, unsigned long* inc);
-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);
-} *thd_rnd_service;
-double thd_rnd(void* thd);
-void thd_create_random_password(void* thd, char *to, size_t length);
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);
@@ -242,6 +273,12 @@
char *thd_get_error_context_description(void* thd,
char *buffer, unsigned int length,
unsigned int max_query_length);
+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);
+} *thd_rnd_service;
+double thd_rnd(void* thd);
+void thd_create_random_password(void* thd, char *to, size_t length);
typedef int MYSQL_THD_KEY_T;
extern struct thd_specifics_service_st {
int (*thd_key_create_func)(MYSQL_THD_KEY_T *key);
@@ -253,82 +290,45 @@
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);
-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)
+typedef long my_time_t;
+enum enum_mysql_timestamp_type
{
- 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;
-}
-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);
+ MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
+ MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
};
-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);
+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 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);
+} *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);
+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)(void*, int);
+ void (*thd_wait_end_func)(void*);
+} *thd_wait_service;
+void thd_wait_begin(void* thd, int wait_type);
+void thd_wait_end(void* thd);
struct st_mysql_xid {
long formatID;
long gtrid_length;
diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp
index 44ac17fbc7b37..6004f4b61aae7 100644
--- a/include/mysql/plugin_ftparser.h.pp
+++ b/include/mysql/plugin_ftparser.h.pp
@@ -1,54 +1,148 @@
typedef char my_bool;
typedef void * MYSQL_PLUGIN;
+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 base64_needed_encoded_length(int length_of_data);
+int base64_encode_max_arg_length(void);
+int base64_needed_decoded_length(int length_of_encoded_data);
+int base64_decode_max_arg_length();
+int base64_encode(const void *src, size_t src_len, char *dst);
+int 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);
+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;
+}
+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);
+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*);
+} *thd_kill_statement_service;
+enum thd_kill_levels thd_kill_level(const void*);
+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 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 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);
-struct st_mysql_lex_string
-{
- char *str;
- size_t length;
-};
-typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
-extern struct thd_alloc_service_st {
- void *(*thd_alloc_func)(void*, unsigned int);
- void *(*thd_calloc_func)(void*, unsigned int);
- char *(*thd_strdup_func)(void*, const char *);
- char *(*thd_strmake_func)(void*, const char *, unsigned int);
- void *(*thd_memdup_func)(void*, const void*, unsigned int);
- MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
- const char *, unsigned int, int);
-} *thd_alloc_service;
-void *thd_alloc(void* thd, unsigned int size);
-void *thd_calloc(void* thd, unsigned int size);
-char *thd_strdup(void* thd, const char *str);
-char *thd_strmake(void* thd, const char *str, unsigned int size);
-void *thd_memdup(void* thd, const void* str, unsigned int size);
-MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
- const char *str, unsigned int size,
- int allocate_lex_string);
-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)(void*, int);
- void (*thd_wait_end_func)(void*);
-} *thd_wait_service;
-void thd_wait_begin(void* thd, int wait_type);
-void thd_wait_end(void* thd);
extern struct progress_report_service_st {
void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
void (*thd_progress_report_func)(void* thd,
@@ -69,35 +163,20 @@
void thd_progress_end(void* thd);
const char *set_thd_proc_info(void*, const char * info, const char *func,
const char *file, unsigned int line);
-extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
-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*);
-} *thd_kill_statement_service;
-enum thd_kill_levels thd_kill_level(const void*);
-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 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);
-} *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);
+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 struct my_sha2_service_st {
void (*my_sha224_type)(unsigned char*, const char*, size_t);
void (*my_sha224_multi_type)(unsigned char*, ...);
@@ -148,83 +227,35 @@
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 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 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 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 base64_needed_encoded_length(int length_of_data);
-int base64_encode_max_arg_length(void);
-int base64_needed_decoded_length(int length_of_encoded_data);
-int base64_decode_max_arg_length();
-int base64_encode(const void *src, size_t src_len, char *dst);
-int base64_decode(const char *src, size_t src_len,
- void *dst, const char **end_ptr, int flags);
-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);
+struct st_mysql_lex_string
+{
+ char *str;
+ size_t length;
+};
+typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+extern struct thd_alloc_service_st {
+ void *(*thd_alloc_func)(void*, unsigned int);
+ void *(*thd_calloc_func)(void*, unsigned int);
+ char *(*thd_strdup_func)(void*, const char *);
+ char *(*thd_strmake_func)(void*, const char *, unsigned int);
+ void *(*thd_memdup_func)(void*, const void*, unsigned int);
+ MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
+ const char *, unsigned int, int);
+} *thd_alloc_service;
+void *thd_alloc(void* thd, unsigned int size);
+void *thd_calloc(void* thd, unsigned int size);
+char *thd_strdup(void* thd, const char *str);
+char *thd_strmake(void* thd, const char *str, unsigned int size);
+void *thd_memdup(void* thd, const void* str, unsigned int size);
+MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
+ const char *str, unsigned int size,
+ int allocate_lex_string);
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc);
} *thd_autoinc_service;
void thd_get_autoinc(const void* thd,
unsigned long* off, unsigned long* inc);
-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);
-} *thd_rnd_service;
-double thd_rnd(void* thd);
-void thd_create_random_password(void* thd, char *to, size_t length);
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);
@@ -242,6 +273,12 @@
char *thd_get_error_context_description(void* thd,
char *buffer, unsigned int length,
unsigned int max_query_length);
+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);
+} *thd_rnd_service;
+double thd_rnd(void* thd);
+void thd_create_random_password(void* thd, char *to, size_t length);
typedef int MYSQL_THD_KEY_T;
extern struct thd_specifics_service_st {
int (*thd_key_create_func)(MYSQL_THD_KEY_T *key);
@@ -253,82 +290,45 @@
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);
-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)
+typedef long my_time_t;
+enum enum_mysql_timestamp_type
{
- 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;
-}
-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);
+ MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
+ MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
};
-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);
+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 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);
+} *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);
+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)(void*, int);
+ void (*thd_wait_end_func)(void*);
+} *thd_wait_service;
+void thd_wait_begin(void* thd, int wait_type);
+void thd_wait_end(void* thd);
struct st_mysql_xid {
long formatID;
long gtrid_length;
diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp
index 8851ae77b4a94..966d92ae5adbf 100644
--- a/include/mysql/plugin_password_validation.h.pp
+++ b/include/mysql/plugin_password_validation.h.pp
@@ -1,54 +1,148 @@
typedef char my_bool;
typedef void * MYSQL_PLUGIN;
+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 base64_needed_encoded_length(int length_of_data);
+int base64_encode_max_arg_length(void);
+int base64_needed_decoded_length(int length_of_encoded_data);
+int base64_decode_max_arg_length();
+int base64_encode(const void *src, size_t src_len, char *dst);
+int 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);
+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;
+}
+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);
+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*);
+} *thd_kill_statement_service;
+enum thd_kill_levels thd_kill_level(const void*);
+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 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 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);
-struct st_mysql_lex_string
-{
- char *str;
- size_t length;
-};
-typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
-extern struct thd_alloc_service_st {
- void *(*thd_alloc_func)(void*, unsigned int);
- void *(*thd_calloc_func)(void*, unsigned int);
- char *(*thd_strdup_func)(void*, const char *);
- char *(*thd_strmake_func)(void*, const char *, unsigned int);
- void *(*thd_memdup_func)(void*, const void*, unsigned int);
- MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
- const char *, unsigned int, int);
-} *thd_alloc_service;
-void *thd_alloc(void* thd, unsigned int size);
-void *thd_calloc(void* thd, unsigned int size);
-char *thd_strdup(void* thd, const char *str);
-char *thd_strmake(void* thd, const char *str, unsigned int size);
-void *thd_memdup(void* thd, const void* str, unsigned int size);
-MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
- const char *str, unsigned int size,
- int allocate_lex_string);
-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)(void*, int);
- void (*thd_wait_end_func)(void*);
-} *thd_wait_service;
-void thd_wait_begin(void* thd, int wait_type);
-void thd_wait_end(void* thd);
extern struct progress_report_service_st {
void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
void (*thd_progress_report_func)(void* thd,
@@ -69,35 +163,20 @@
void thd_progress_end(void* thd);
const char *set_thd_proc_info(void*, const char * info, const char *func,
const char *file, unsigned int line);
-extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t);
-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*);
-} *thd_kill_statement_service;
-enum thd_kill_levels thd_kill_level(const void*);
-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 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);
-} *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);
+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 struct my_sha2_service_st {
void (*my_sha224_type)(unsigned char*, const char*, size_t);
void (*my_sha224_multi_type)(unsigned char*, ...);
@@ -148,83 +227,35 @@
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 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 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 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 base64_needed_encoded_length(int length_of_data);
-int base64_encode_max_arg_length(void);
-int base64_needed_decoded_length(int length_of_encoded_data);
-int base64_decode_max_arg_length();
-int base64_encode(const void *src, size_t src_len, char *dst);
-int base64_decode(const char *src, size_t src_len,
- void *dst, const char **end_ptr, int flags);
-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);
+struct st_mysql_lex_string
+{
+ char *str;
+ size_t length;
+};
+typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
+extern struct thd_alloc_service_st {
+ void *(*thd_alloc_func)(void*, unsigned int);
+ void *(*thd_calloc_func)(void*, unsigned int);
+ char *(*thd_strdup_func)(void*, const char *);
+ char *(*thd_strmake_func)(void*, const char *, unsigned int);
+ void *(*thd_memdup_func)(void*, const void*, unsigned int);
+ MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *,
+ const char *, unsigned int, int);
+} *thd_alloc_service;
+void *thd_alloc(void* thd, unsigned int size);
+void *thd_calloc(void* thd, unsigned int size);
+char *thd_strdup(void* thd, const char *str);
+char *thd_strmake(void* thd, const char *str, unsigned int size);
+void *thd_memdup(void* thd, const void* str, unsigned int size);
+MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str,
+ const char *str, unsigned int size,
+ int allocate_lex_string);
extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc);
} *thd_autoinc_service;
void thd_get_autoinc(const void* thd,
unsigned long* off, unsigned long* inc);
-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);
-} *thd_rnd_service;
-double thd_rnd(void* thd);
-void thd_create_random_password(void* thd, char *to, size_t length);
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);
@@ -242,6 +273,12 @@
char *thd_get_error_context_description(void* thd,
char *buffer, unsigned int length,
unsigned int max_query_length);
+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);
+} *thd_rnd_service;
+double thd_rnd(void* thd);
+void thd_create_random_password(void* thd, char *to, size_t length);
typedef int MYSQL_THD_KEY_T;
extern struct thd_specifics_service_st {
int (*thd_key_create_func)(MYSQL_THD_KEY_T *key);
@@ -253,82 +290,45 @@
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);
-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)
+typedef long my_time_t;
+enum enum_mysql_timestamp_type
{
- 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;
-}
-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);
+ MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1,
+ MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2
};
-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);
+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 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);
+} *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);
+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)(void*, int);
+ void (*thd_wait_end_func)(void*);
+} *thd_wait_service;
+void thd_wait_begin(void* thd, int wait_type);
+void thd_wait_end(void* thd);
struct st_mysql_xid {
long formatID;
long gtrid_length;
diff --git a/include/mysql/services.h b/include/mysql/services.h
index 6cb5f50dc8208..420f2430a3609 100644
--- a/include/mysql/services.h
+++ b/include/mysql/services.h
@@ -19,24 +19,24 @@
extern "C" {
#endif
-#include
-#include
-#include
-#include
+#include
#include
+#include
+#include
#include
-#include
-#include
-#include
-#include
-#include
#include
+#include
+#include
+#include
+#include
+#include
+#include
#include
-#include
#include
+#include
#include
-#include
-#include
+#include
+#include
/*#include */
#ifdef __cplusplus
diff --git a/include/service_versions.h b/include/service_versions.h
index a083179264391..d79474f1d36cf 100644
--- a/include/service_versions.h
+++ b/include/service_versions.h
@@ -23,21 +23,20 @@
#define VERSION_debug_sync 0x1000
#define VERSION_kill_statement 0x1000
+#define VERSION_base64 0x0100
+#define VERSION_encryption 0x0300
+#define VERSION_encryption_scheme 0x0100
+#define VERSION_logger 0x0100
+#define VERSION_my_md5 0x0100
+#define VERSION_my_sha1 0x0101
+#define VERSION_my_sha2 0x0100
#define VERSION_my_snprintf 0x0100
-#define VERSION_thd_alloc 0x0100
-#define VERSION_thd_wait 0x0100
#define VERSION_progress_report 0x0100
-#define VERSION_thd_timezone 0x0100
-#define VERSION_my_sha2 0x0100
-#define VERSION_my_sha1 0x0101
-#define VERSION_my_md5 0x0100
-#define VERSION_wsrep 0x0201
-#define VERSION_logger 0x0100
-#define VERSION_base64 0x0100
-#define VERSION_thd_rnd 0x0100
+#define VERSION_thd_alloc 0x0100
#define VERSION_thd_autoinc 0x0100
#define VERSION_thd_error_context 0x0100
+#define VERSION_thd_rnd 0x0100
#define VERSION_thd_specifics 0x0100
-#define VERSION_encryption 0x0300
-#define VERSION_encryption_scheme 0x0100
-
+#define VERSION_thd_timezone 0x0100
+#define VERSION_thd_wait 0x0100
+#define VERSION_wsrep 0x0201
diff --git a/libservices/CMakeLists.txt b/libservices/CMakeLists.txt
index 5c789885b50a2..0b68a15607788 100644
--- a/libservices/CMakeLists.txt
+++ b/libservices/CMakeLists.txt
@@ -16,25 +16,26 @@
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
SET(MYSQLSERVICES_SOURCES
+ base64_service.c
+ debug_sync_service.c
+ encryption_scheme_service.c
+ encryption_service.c
+ kill_statement_service.c
+ logger_service.c
+ my_md5_service.c
+ my_sha1_service.c
+ my_sha2_service.c
my_snprintf_service.c
+ progress_report_service.c
thd_alloc_service.c
- thd_wait_service.c
- thd_timezone_service.c
thd_autoinc_service.c
thd_error_context_service.c
thd_rnd_service.c
thd_specifics_service.c
- progress_report_service.c
- debug_sync_service.c
- my_sha2_service.c
- my_sha1_service.c
- my_md5_service.c
- base64_service.c
+ thd_timezone_service.c
+ thd_wait_service.c
wsrep_service.c
- encryption_service.c
- encryption_scheme_service.c
- kill_statement_service.c
- logger_service.c)
+)
ADD_CONVENIENCE_LIBRARY(mysqlservices ${MYSQLSERVICES_SOURCES})
INSTALL(TARGETS mysqlservices DESTINATION ${INSTALL_LIBDIR} COMPONENT Development)
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 14c9071a283bf..eacf39098b4d3 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -1550,8 +1550,8 @@ int plugin_init(int *argc, char **argv, int flags)
}
/* prepare debug_sync service */
- DBUG_ASSERT(strcmp(list_of_services[4].name, "debug_sync_service") == 0);
- list_of_services[4].service= *(void**)&debug_sync_C_callback_ptr;
+ DBUG_ASSERT(strcmp(list_of_services[1].name, "debug_sync_service") == 0);
+ list_of_services[1].service= *(void**)&debug_sync_C_callback_ptr;
/* prepare encryption_keys service */
finalize_encryption_plugin(0);
diff --git a/sql/sql_plugin_services.ic b/sql/sql_plugin_services.ic
index 564276a852a48..8e651d64ba187 100644
--- a/sql/sql_plugin_services.ic
+++ b/sql/sql_plugin_services.ic
@@ -198,24 +198,24 @@ static struct encryption_scheme_service_st encryption_scheme_handler=
static struct st_service_ref list_of_services[]=
{
+ { "base64_service", VERSION_base64, &base64_handler },
+ { "debug_sync_service", VERSION_debug_sync, 0 }, // updated in plugin_init()
+ { "encryption_scheme_service", VERSION_encryption_scheme, &encryption_scheme_handler },
+ { "encryption_service", VERSION_encryption, &encryption_handler },
+ { "logger_service", VERSION_logger, &logger_service_handler },
+ { "my_md5_service", VERSION_my_md5, &my_md5_handler},
+ { "my_sha1_service", VERSION_my_sha1, &my_sha1_handler},
+ { "my_sha2_service", VERSION_my_sha2, &my_sha2_handler},
{ "my_snprintf_service", VERSION_my_snprintf, &my_snprintf_handler },
- { "thd_alloc_service", VERSION_thd_alloc, &thd_alloc_handler },
- { "thd_wait_service", VERSION_thd_wait, &thd_wait_handler },
{ "progress_report_service", VERSION_progress_report, &progress_report_handler },
- { "debug_sync_service", VERSION_debug_sync, 0 }, // updated in plugin_init()
+ { "thd_alloc_service", VERSION_thd_alloc, &thd_alloc_handler },
+ { "thd_autoinc_service", VERSION_thd_autoinc, &thd_autoinc_handler },
+ { "thd_error_context_service", VERSION_thd_error_context, &thd_error_conext_handler },
{ "thd_kill_statement_service", VERSION_kill_statement, &thd_kill_statement_handler },
- { "thd_timezone_service", VERSION_thd_timezone, &thd_timezone_handler },
- { "my_sha2_service", VERSION_my_sha2, &my_sha2_handler},
- { "my_sha1_service", VERSION_my_sha1, &my_sha1_handler},
- { "my_md5_service", VERSION_my_md5, &my_md5_handler},
- { "logger_service", VERSION_logger, &logger_service_handler },
- { "base64_service", VERSION_base64, &base64_handler },
{ "thd_rnd_service", VERSION_thd_rnd, &thd_rnd_handler },
- { "thd_autoinc_service", VERSION_thd_autoinc, &thd_autoinc_handler },
- { "wsrep_service", VERSION_wsrep, &wsrep_handler },
- { "encryption_service", VERSION_encryption, &encryption_handler },
- { "encryption_scheme_service", VERSION_encryption_scheme, &encryption_scheme_handler },
{ "thd_specifics_service", VERSION_thd_specifics, &thd_specifics_handler },
- { "thd_error_context_service", VERSION_thd_error_context, &thd_error_conext_handler },
+ { "thd_timezone_service", VERSION_thd_timezone, &thd_timezone_handler },
+ { "thd_wait_service", VERSION_thd_wait, &thd_wait_handler },
+ { "wsrep_service", VERSION_wsrep, &wsrep_handler },
};
From 269ab56f8b4056ec63e712ba305761dd835ea10e Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Mon, 6 Mar 2017 22:42:00 +0100
Subject: [PATCH 186/226] small plugin API related fixes
* define MYSQL_DYNAMIC_PLUGIN only for server plugins
* don't typedef my_bool in mysql.h if plugin.h has already done it
* fix the include guard in plugin.h
---
cmake/plugin.cmake | 7 +++++--
include/mysql.h | 4 ++++
include/mysql/plugin.h | 4 ++--
libmysql/get_password.c | 2 +-
plugin/auth_dialog/CMakeLists.txt | 1 +
5 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake
index 818264f9edfcf..3fbb19381bc59 100644
--- a/cmake/plugin.cmake
+++ b/cmake/plugin.cmake
@@ -186,8 +186,11 @@ MACRO(MYSQL_ADD_PLUGIN)
ADD_LIBRARY(${target} MODULE ${SOURCES})
DTRACE_INSTRUMENT(${target})
- SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX ""
- COMPILE_DEFINITIONS "MYSQL_DYNAMIC_PLUGIN")
+ SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX "")
+ IF (NOT ARG_CLIENT)
+ SET_TARGET_PROPERTIES (${target} PROPERTIES
+ COMPILE_DEFINITIONS "MYSQL_DYNAMIC_PLUGIN")
+ ENDIF()
TARGET_LINK_LIBRARIES (${target} mysqlservices ${ARG_LINK_LIBRARIES})
diff --git a/include/mysql.h b/include/mysql.h
index f088ad668a1d8..53c86aee889d1 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -48,7 +48,11 @@ extern "C" {
#ifndef MYSQL_ABI_CHECK
#include
#endif
+
+#ifndef MYSQL_PLUGIN_INCLUDED
typedef char my_bool;
+#endif
+
#if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__)
#define __WIN__
#endif
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h
index 255d009f0299d..a5bfa1bbc9e88 100644
--- a/include/mysql/plugin.h
+++ b/include/mysql/plugin.h
@@ -14,8 +14,8 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
-#ifndef _my_plugin_h
-#define _my_plugin_h
+#ifndef MYSQL_PLUGIN_INCLUDED
+#define MYSQL_PLUGIN_INCLUDED
/*
On Windows, exports from DLL need to be declared
diff --git a/libmysql/get_password.c b/libmysql/get_password.c
index e704aec8337fc..36f8f9b08454e 100644
--- a/libmysql/get_password.c
+++ b/libmysql/get_password.c
@@ -217,7 +217,7 @@ void get_tty_password_buff(const char *opt_message, char *buff, size_t buflen)
}
#endif /*__WIN__*/
-#ifndef MYSQL_DYNAMIC_PLUGIN
+#ifndef NO_GET_TTY_PASSWORD
char *get_tty_password(const char *opt_message)
{
char buff[80];
diff --git a/plugin/auth_dialog/CMakeLists.txt b/plugin/auth_dialog/CMakeLists.txt
index 7253b2b2f97fd..771bc615bd54b 100644
--- a/plugin/auth_dialog/CMakeLists.txt
+++ b/plugin/auth_dialog/CMakeLists.txt
@@ -14,5 +14,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ADD_DEFINITIONS(-DNO_GET_TTY_PASSWORD)
MYSQL_ADD_PLUGIN(dialog dialog.c ${CMAKE_SOURCE_DIR}/libmysql/get_password.c
MODULE_ONLY CLIENT COMPONENT ClientPlugins)
From 7120118a5e97477778715ebdc8e4fba548a6dc87 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik
Date: Sun, 5 Mar 2017 16:18:16 +0100
Subject: [PATCH 187/226] MDEV-12160 Modern alternative to the SHA1
authentication plugin
ED25519 authentication plugin
---
.../suite/plugins/r/auth_ed25519.result | 50 +
mysql-test/suite/plugins/t/auth_ed25519.test | 44 +
plugin/auth_ed25519/CMakeLists.txt | 25 +
plugin/auth_ed25519/README | 12 +
plugin/auth_ed25519/client_ed25519.c | 72 +
plugin/auth_ed25519/common.h | 32 +
plugin/auth_ed25519/crypto_hash_sha256.h | 2 +
plugin/auth_ed25519/crypto_hash_sha512.h | 2 +
plugin/auth_ed25519/crypto_int32.h | 5 +
plugin/auth_ed25519/crypto_int64.h | 5 +
plugin/auth_ed25519/crypto_sign.h | 11 +
plugin/auth_ed25519/crypto_uint32.h | 5 +
plugin/auth_ed25519/crypto_uint64.h | 5 +
plugin/auth_ed25519/crypto_verify.h | 1 +
plugin/auth_ed25519/crypto_verify_32.h | 2 +
plugin/auth_ed25519/ed25519-t.c | 58 +
plugin/auth_ed25519/randombytes.h | 1 +
plugin/auth_ed25519/ref10/api.h | 4 +
plugin/auth_ed25519/ref10/base.h | 1344 +++++++++++++++++
plugin/auth_ed25519/ref10/base2.h | 40 +
plugin/auth_ed25519/ref10/d.h | 1 +
plugin/auth_ed25519/ref10/d2.h | 1 +
plugin/auth_ed25519/ref10/fe.h | 56 +
plugin/auth_ed25519/ref10/fe_0.c | 19 +
plugin/auth_ed25519/ref10/fe_1.c | 19 +
plugin/auth_ed25519/ref10/fe_add.c | 57 +
plugin/auth_ed25519/ref10/fe_cmov.c | 63 +
plugin/auth_ed25519/ref10/fe_copy.c | 29 +
plugin/auth_ed25519/ref10/fe_frombytes.c | 73 +
plugin/auth_ed25519/ref10/fe_invert.c | 14 +
plugin/auth_ed25519/ref10/fe_isnegative.c | 16 +
plugin/auth_ed25519/ref10/fe_isnonzero.c | 19 +
plugin/auth_ed25519/ref10/fe_mul.c | 253 ++++
plugin/auth_ed25519/ref10/fe_neg.c | 45 +
plugin/auth_ed25519/ref10/fe_pow22523.c | 13 +
plugin/auth_ed25519/ref10/fe_sq.c | 149 ++
plugin/auth_ed25519/ref10/fe_sq2.c | 160 ++
plugin/auth_ed25519/ref10/fe_sub.c | 57 +
plugin/auth_ed25519/ref10/fe_tobytes.c | 119 ++
plugin/auth_ed25519/ref10/ge.h | 95 ++
plugin/auth_ed25519/ref10/ge_add.c | 11 +
plugin/auth_ed25519/ref10/ge_add.h | 97 ++
.../auth_ed25519/ref10/ge_double_scalarmult.c | 96 ++
plugin/auth_ed25519/ref10/ge_frombytes.c | 50 +
plugin/auth_ed25519/ref10/ge_madd.c | 11 +
plugin/auth_ed25519/ref10/ge_madd.h | 88 ++
plugin/auth_ed25519/ref10/ge_msub.c | 11 +
plugin/auth_ed25519/ref10/ge_msub.h | 88 ++
plugin/auth_ed25519/ref10/ge_p1p1_to_p2.c | 12 +
plugin/auth_ed25519/ref10/ge_p1p1_to_p3.c | 13 +
plugin/auth_ed25519/ref10/ge_p2_0.c | 8 +
plugin/auth_ed25519/ref10/ge_p2_dbl.c | 11 +
plugin/auth_ed25519/ref10/ge_p2_dbl.h | 73 +
plugin/auth_ed25519/ref10/ge_p3_0.c | 9 +
plugin/auth_ed25519/ref10/ge_p3_dbl.c | 12 +
plugin/auth_ed25519/ref10/ge_p3_to_cached.c | 17 +
plugin/auth_ed25519/ref10/ge_p3_to_p2.c | 12 +
plugin/auth_ed25519/ref10/ge_p3_tobytes.c | 14 +
plugin/auth_ed25519/ref10/ge_precomp_0.c | 8 +
.../auth_ed25519/ref10/ge_scalarmult_base.c | 105 ++
plugin/auth_ed25519/ref10/ge_sub.c | 11 +
plugin/auth_ed25519/ref10/ge_sub.h | 97 ++
plugin/auth_ed25519/ref10/ge_tobytes.c | 14 +
plugin/auth_ed25519/ref10/keypair.c | 23 +
plugin/auth_ed25519/ref10/open.c | 48 +
plugin/auth_ed25519/ref10/pow22523.h | 160 ++
plugin/auth_ed25519/ref10/pow225521.h | 160 ++
plugin/auth_ed25519/ref10/sc.h | 15 +
plugin/auth_ed25519/ref10/sc_muladd.c | 368 +++++
plugin/auth_ed25519/ref10/sc_reduce.c | 275 ++++
plugin/auth_ed25519/ref10/sign.c | 41 +
plugin/auth_ed25519/ref10/sqrtm1.h | 1 +
plugin/auth_ed25519/ref10/verify.c | 40 +
plugin/auth_ed25519/server_ed25519.c | 147 ++
74 files changed, 5124 insertions(+)
create mode 100644 mysql-test/suite/plugins/r/auth_ed25519.result
create mode 100644 mysql-test/suite/plugins/t/auth_ed25519.test
create mode 100644 plugin/auth_ed25519/CMakeLists.txt
create mode 100644 plugin/auth_ed25519/README
create mode 100644 plugin/auth_ed25519/client_ed25519.c
create mode 100644 plugin/auth_ed25519/common.h
create mode 100644 plugin/auth_ed25519/crypto_hash_sha256.h
create mode 100644 plugin/auth_ed25519/crypto_hash_sha512.h
create mode 100644 plugin/auth_ed25519/crypto_int32.h
create mode 100644 plugin/auth_ed25519/crypto_int64.h
create mode 100644 plugin/auth_ed25519/crypto_sign.h
create mode 100644 plugin/auth_ed25519/crypto_uint32.h
create mode 100644 plugin/auth_ed25519/crypto_uint64.h
create mode 100644 plugin/auth_ed25519/crypto_verify.h
create mode 100644 plugin/auth_ed25519/crypto_verify_32.h
create mode 100644 plugin/auth_ed25519/ed25519-t.c
create mode 100644 plugin/auth_ed25519/randombytes.h
create mode 100644 plugin/auth_ed25519/ref10/api.h
create mode 100644 plugin/auth_ed25519/ref10/base.h
create mode 100644 plugin/auth_ed25519/ref10/base2.h
create mode 100644 plugin/auth_ed25519/ref10/d.h
create mode 100644 plugin/auth_ed25519/ref10/d2.h
create mode 100644 plugin/auth_ed25519/ref10/fe.h
create mode 100644 plugin/auth_ed25519/ref10/fe_0.c
create mode 100644 plugin/auth_ed25519/ref10/fe_1.c
create mode 100644 plugin/auth_ed25519/ref10/fe_add.c
create mode 100644 plugin/auth_ed25519/ref10/fe_cmov.c
create mode 100644 plugin/auth_ed25519/ref10/fe_copy.c
create mode 100644 plugin/auth_ed25519/ref10/fe_frombytes.c
create mode 100644 plugin/auth_ed25519/ref10/fe_invert.c
create mode 100644 plugin/auth_ed25519/ref10/fe_isnegative.c
create mode 100644 plugin/auth_ed25519/ref10/fe_isnonzero.c
create mode 100644 plugin/auth_ed25519/ref10/fe_mul.c
create mode 100644 plugin/auth_ed25519/ref10/fe_neg.c
create mode 100644 plugin/auth_ed25519/ref10/fe_pow22523.c
create mode 100644 plugin/auth_ed25519/ref10/fe_sq.c
create mode 100644 plugin/auth_ed25519/ref10/fe_sq2.c
create mode 100644 plugin/auth_ed25519/ref10/fe_sub.c
create mode 100644 plugin/auth_ed25519/ref10/fe_tobytes.c
create mode 100644 plugin/auth_ed25519/ref10/ge.h
create mode 100644 plugin/auth_ed25519/ref10/ge_add.c
create mode 100644 plugin/auth_ed25519/ref10/ge_add.h
create mode 100644 plugin/auth_ed25519/ref10/ge_double_scalarmult.c
create mode 100644 plugin/auth_ed25519/ref10/ge_frombytes.c
create mode 100644 plugin/auth_ed25519/ref10/ge_madd.c
create mode 100644 plugin/auth_ed25519/ref10/ge_madd.h
create mode 100644 plugin/auth_ed25519/ref10/ge_msub.c
create mode 100644 plugin/auth_ed25519/ref10/ge_msub.h
create mode 100644 plugin/auth_ed25519/ref10/ge_p1p1_to_p2.c
create mode 100644 plugin/auth_ed25519/ref10/ge_p1p1_to_p3.c
create mode 100644 plugin/auth_ed25519/ref10/ge_p2_0.c
create mode 100644 plugin/auth_ed25519/ref10/ge_p2_dbl.c
create mode 100644 plugin/auth_ed25519/ref10/ge_p2_dbl.h
create mode 100644 plugin/auth_ed25519/ref10/ge_p3_0.c
create mode 100644 plugin/auth_ed25519/ref10/ge_p3_dbl.c
create mode 100644 plugin/auth_ed25519/ref10/ge_p3_to_cached.c
create mode 100644 plugin/auth_ed25519/ref10/ge_p3_to_p2.c
create mode 100644 plugin/auth_ed25519/ref10/ge_p3_tobytes.c
create mode 100644 plugin/auth_ed25519/ref10/ge_precomp_0.c
create mode 100644 plugin/auth_ed25519/ref10/ge_scalarmult_base.c
create mode 100644 plugin/auth_ed25519/ref10/ge_sub.c
create mode 100644 plugin/auth_ed25519/ref10/ge_sub.h
create mode 100644 plugin/auth_ed25519/ref10/ge_tobytes.c
create mode 100644 plugin/auth_ed25519/ref10/keypair.c
create mode 100644 plugin/auth_ed25519/ref10/open.c
create mode 100644 plugin/auth_ed25519/ref10/pow22523.h
create mode 100644 plugin/auth_ed25519/ref10/pow225521.h
create mode 100644 plugin/auth_ed25519/ref10/sc.h
create mode 100644 plugin/auth_ed25519/ref10/sc_muladd.c
create mode 100644 plugin/auth_ed25519/ref10/sc_reduce.c
create mode 100644 plugin/auth_ed25519/ref10/sign.c
create mode 100644 plugin/auth_ed25519/ref10/sqrtm1.h
create mode 100644 plugin/auth_ed25519/ref10/verify.c
create mode 100644 plugin/auth_ed25519/server_ed25519.c
diff --git a/mysql-test/suite/plugins/r/auth_ed25519.result b/mysql-test/suite/plugins/r/auth_ed25519.result
new file mode 100644
index 0000000000000..51363fea60b37
--- /dev/null
+++ b/mysql-test/suite/plugins/r/auth_ed25519.result
@@ -0,0 +1,50 @@
+create function ed25519_password returns string soname "auth_ed25519.so";
+select ed25519_password();
+ERROR HY000: Can't initialize function 'ed25519_password'; Wrong arguments to ed25519_password()
+select ed25519_password(1);
+ERROR HY000: Can't initialize function 'ed25519_password'; Wrong arguments to ed25519_password()
+select ed25519_password("foo", "bar");
+ERROR HY000: Can't initialize function 'ed25519_password'; Wrong arguments to ed25519_password()
+select ed25519_password("foo");
+ERROR HY000: Can't initialize function 'ed25519_password'; Authentication plugin ed25519 is not loaded
+install soname 'auth_ed25519';
+select ed25519_password("foo");
+ed25519_password("foo")
+NNJledu0Vmk+VAZyz5IvUt3g1lMuNb8GvgE6fFMvIOA
+select ed25519_password("foobar");
+ed25519_password("foobar")
+LgZlMsxPDw66qLCfGWRu4IVKqzyAqlA1aXSZbax5maE
+select ed25519_password("foo bar");
+ed25519_password("foo bar")
+6EFKeQLw+p5Ovk8tD+tAi3Agyg7ItukdswOBpTB6f40
+select ed25519_password(NULL);
+ed25519_password(NULL)
+NULL
+select * from information_schema.plugins where plugin_name='ed25519';
+PLUGIN_NAME ed25519
+PLUGIN_VERSION 1.0
+PLUGIN_STATUS ACTIVE
+PLUGIN_TYPE AUTHENTICATION
+PLUGIN_TYPE_VERSION 2.1
+PLUGIN_LIBRARY auth_ed25519.so
+PLUGIN_LIBRARY_VERSION 1.12
+PLUGIN_AUTHOR Sergei Golubchik
+PLUGIN_DESCRIPTION Elliptic curve ED25519 based authentication
+PLUGIN_LICENSE GPL
+LOAD_OPTION ON
+PLUGIN_MATURITY Beta
+PLUGIN_AUTH_VERSION 1.0-alpha
+create user test1@localhost identified via ed25519 using 'XQNqhYzon4REkXYuuJ4r+9UKSgoNpljksmKLJbEXrgk';
+show grants for test1@localhost;
+Grants for test1@localhost
+GRANT USAGE ON *.* TO 'test1'@'localhost' IDENTIFIED VIA ed25519 USING 'XQNqhYzon4REkXYuuJ4r+9UKSgoNpljksmKLJbEXrgk'
+connect(localhost,test1,public,test,PORT,SOCKET);
+ERROR 28000: Access denied for user 'test1'@'localhost' (using password: YES)
+select current_user();
+current_user()
+test1@localhost
+drop user test1@localhost;
+uninstall plugin ed25519;
+select ed25519_password("foo");
+ERROR HY000: Can't initialize function 'ed25519_password'; Authentication plugin ed25519 is not loaded
+drop function ed25519_password;
diff --git a/mysql-test/suite/plugins/t/auth_ed25519.test b/mysql-test/suite/plugins/t/auth_ed25519.test
new file mode 100644
index 0000000000000..3e02bdf97d2b1
--- /dev/null
+++ b/mysql-test/suite/plugins/t/auth_ed25519.test
@@ -0,0 +1,44 @@
+#
+# MDEV-12160 Modern alternative to the SHA1 authentication plugin
+#
+source include/not_embedded.inc;
+if (!$AUTH_ED25519_SO) {
+ skip No auth_ed25519 plugin;
+}
+
+replace_result dll so;
+eval create function ed25519_password returns string soname "$AUTH_ED25519_SO";
+error ER_CANT_INITIALIZE_UDF;
+select ed25519_password();
+error ER_CANT_INITIALIZE_UDF;
+select ed25519_password(1);
+error ER_CANT_INITIALIZE_UDF;
+select ed25519_password("foo", "bar");
+error ER_CANT_INITIALIZE_UDF;
+select ed25519_password("foo");
+
+install soname 'auth_ed25519';
+select ed25519_password("foo");
+select ed25519_password("foobar");
+select ed25519_password("foo bar");
+select ed25519_password(NULL);
+
+replace_result dll so;
+query_vertical select * from information_schema.plugins where plugin_name='ed25519';
+let $pwd=`select ed25519_password("secret")`;
+eval create user test1@localhost identified via ed25519 using '$pwd';
+show grants for test1@localhost;
+
+replace_result $MASTER_MYPORT PORT $MASTER_MYSOCK SOCKET;
+error ER_ACCESS_DENIED_ERROR;
+connect con1, localhost, test1, public;
+connect con1, localhost, test1, secret;
+select current_user();
+disconnect con1;
+connection default;
+
+drop user test1@localhost;
+uninstall plugin ed25519;
+error ER_CANT_INITIALIZE_UDF;
+select ed25519_password("foo");
+drop function ed25519_password;
diff --git a/plugin/auth_ed25519/CMakeLists.txt b/plugin/auth_ed25519/CMakeLists.txt
new file mode 100644
index 0000000000000..fb3a841ef9d99
--- /dev/null
+++ b/plugin/auth_ed25519/CMakeLists.txt
@@ -0,0 +1,25 @@
+SET(REF10_SOURCES
+ ref10/fe_0.c ref10/fe_1.c ref10/fe_add.c ref10/fe_cmov.c ref10/fe_copy.c
+ ref10/fe_frombytes.c ref10/fe_invert.c ref10/fe_isnegative.c
+ ref10/fe_isnonzero.c ref10/fe_mul.c ref10/fe_neg.c ref10/fe_pow22523.c
+ ref10/fe_sq.c ref10/fe_sq2.c ref10/fe_sub.c ref10/fe_tobytes.c
+ ref10/ge_add.c ref10/ge_double_scalarmult.c ref10/ge_frombytes.c
+ ref10/ge_madd.c ref10/ge_msub.c ref10/ge_p1p1_to_p2.c
+ ref10/ge_p1p1_to_p3.c ref10/ge_p2_0.c ref10/ge_p2_dbl.c ref10/ge_p3_0.c
+ ref10/ge_p3_dbl.c ref10/ge_p3_to_cached.c ref10/ge_p3_to_p2.c
+ ref10/ge_p3_tobytes.c ref10/ge_precomp_0.c ref10/ge_scalarmult_base.c
+ ref10/ge_sub.c ref10/ge_tobytes.c ref10/keypair.c ref10/open.c
+ ref10/sc_muladd.c ref10/sc_reduce.c ref10/sign.c ref10/verify.c)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+ADD_CONVENIENCE_LIBRARY(ref10 ${REF10_SOURCES})
+
+MYSQL_ADD_PLUGIN(auth_ed25519 server_ed25519.c ${REF10_SOURCES} MODULE_ONLY)
+
+MYSQL_ADD_PLUGIN(client_ed25519 client_ed25519.c MODULE_ONLY
+ CLIENT LINK_LIBRARIES mysys_ssl ref10 COMPONENT ClientPlugins)
+
+IF(WITH_UNIT_TESTS)
+ MY_ADD_TESTS(ed25519 LINK_LIBRARIES mysys ref10)
+ENDIF()
diff --git a/plugin/auth_ed25519/README b/plugin/auth_ed25519/README
new file mode 100644
index 0000000000000..aa0263428f40c
--- /dev/null
+++ b/plugin/auth_ed25519/README
@@ -0,0 +1,12 @@
+This plugin uses public domain ed25519 code
+by Daniel J. Bernstein, Niels Duif, Tanja Lange, Peter Schwabe, Bo-Yin Yang.
+
+It is "ref10" implementation from the SUPERCOP:
+https://bench.cr.yp.to/supercop.html
+
+OpenSSH also uses ed25519 from SUPERCOP, but "ref" implementation.
+
+There are four ed25519 implementations in SUPERCOP, ref10 is faster then ref,
+and there are two that are even faster, written in amd64 assembler.
+Benchmarks are here: https://bench.cr.yp.to/impl-sign/ed25519.html
+
diff --git a/plugin/auth_ed25519/client_ed25519.c b/plugin/auth_ed25519/client_ed25519.c
new file mode 100644
index 0000000000000..87ced2c74c24b
--- /dev/null
+++ b/plugin/auth_ed25519/client_ed25519.c
@@ -0,0 +1,72 @@
+/*
+ Copyright (c) 2017, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/************************** CLIENT *************************************/
+
+#include
+#include "common.h"
+#include
+#include
+
+#if !defined(__attribute__) && !defined(__GNUC__)
+#define __attribute__(A)
+#endif
+
+static int do_auth(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)
+{
+ unsigned char sk[CRYPTO_SECRETKEYBYTES], pk[CRYPTO_PUBLICKEYBYTES];
+ unsigned char reply[CRYPTO_BYTES + NONCE_BYTES], *pkt;
+ unsigned long long reply_len;
+ int pkt_len;
+
+ /* compute keys */
+ pw_to_sk_and_pk(mysql->passwd, strlen(mysql->passwd), sk, pk);
+
+ /* read the nonce */
+ if ((pkt_len= vio->read_packet(vio, &pkt)) != NONCE_BYTES)
+ return CR_SERVER_HANDSHAKE_ERR;
+
+ /* sign the nonce */
+ crypto_sign(reply, &reply_len, pkt, NONCE_BYTES, sk);
+
+ /* send the signature */
+ if (vio->write_packet(vio, reply, CRYPTO_BYTES))
+ return CR_ERROR;
+
+ return CR_OK;
+}
+
+static int init_client(char *unused1 __attribute__((unused)),
+ size_t unused2 __attribute__((unused)),
+ int unused3 __attribute__((unused)),
+ va_list unused4 __attribute__((unused)))
+{
+ return 0;
+}
+
+mysql_declare_client_plugin(AUTHENTICATION)
+ "client_ed25519",
+ "Sergei Golubchik",
+ "Elliptic curve ED25519 based authentication",
+ {0,1,0},
+ "GPL",
+ NULL,
+ init_client,
+ NULL,
+ NULL,
+ do_auth,
+mysql_end_client_plugin;
+
diff --git a/plugin/auth_ed25519/common.h b/plugin/auth_ed25519/common.h
new file mode 100644
index 0000000000000..df317535d01e8
--- /dev/null
+++ b/plugin/auth_ed25519/common.h
@@ -0,0 +1,32 @@
+/*
+ Copyright (c) 2017, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include
+#include
+
+#include "ref10/api.h"
+#include "crypto_sign.h"
+#include "crypto_hash_sha256.h"
+
+#define NONCE_BYTES 32
+
+static inline void pw_to_sk_and_pk(const char *pw, size_t pwlen,
+ unsigned char *sk, unsigned char *pk)
+{
+ crypto_hash_sha256(sk, pw, pwlen);
+ crypto_sign_keypair(pk, sk);
+}
+
diff --git a/plugin/auth_ed25519/crypto_hash_sha256.h b/plugin/auth_ed25519/crypto_hash_sha256.h
new file mode 100644
index 0000000000000..557b30b56dd6b
--- /dev/null
+++ b/plugin/auth_ed25519/crypto_hash_sha256.h
@@ -0,0 +1,2 @@
+#include
+#define crypto_hash_sha256(DST,SRC,SLEN) my_sha256(DST,(char*)(SRC),SLEN)
diff --git a/plugin/auth_ed25519/crypto_hash_sha512.h b/plugin/auth_ed25519/crypto_hash_sha512.h
new file mode 100644
index 0000000000000..a1be896f9111b
--- /dev/null
+++ b/plugin/auth_ed25519/crypto_hash_sha512.h
@@ -0,0 +1,2 @@
+#include
+#define crypto_hash_sha512(DST,SRC,SLEN) my_sha512(DST,(char*)(SRC),SLEN)
diff --git a/plugin/auth_ed25519/crypto_int32.h b/plugin/auth_ed25519/crypto_int32.h
new file mode 100644
index 0000000000000..642fca0576700
--- /dev/null
+++ b/plugin/auth_ed25519/crypto_int32.h
@@ -0,0 +1,5 @@
+#include
+#include
+typedef int32_t crypto_int32;
+
+#define select ed25519_select
diff --git a/plugin/auth_ed25519/crypto_int64.h b/plugin/auth_ed25519/crypto_int64.h
new file mode 100644
index 0000000000000..a308e4067213f
--- /dev/null
+++ b/plugin/auth_ed25519/crypto_int64.h
@@ -0,0 +1,5 @@
+#include
+#include
+typedef int64_t crypto_int64;
+
+#define select ed25519_select
diff --git a/plugin/auth_ed25519/crypto_sign.h b/plugin/auth_ed25519/crypto_sign.h
new file mode 100644
index 0000000000000..20c9612172327
--- /dev/null
+++ b/plugin/auth_ed25519/crypto_sign.h
@@ -0,0 +1,11 @@
+int crypto_sign_keypair(unsigned char *pk,unsigned char *sk);
+int crypto_sign(
+ unsigned char *sm, unsigned long long *smlen,
+ const unsigned char *m, unsigned long long mlen,
+ const unsigned char *sk
+);
+int crypto_sign_open(
+ unsigned char *m, unsigned long long *mlen,
+ const unsigned char *sm, unsigned long long smlen,
+ const unsigned char *pk
+);
diff --git a/plugin/auth_ed25519/crypto_uint32.h b/plugin/auth_ed25519/crypto_uint32.h
new file mode 100644
index 0000000000000..ab2977caac24a
--- /dev/null
+++ b/plugin/auth_ed25519/crypto_uint32.h
@@ -0,0 +1,5 @@
+#include
+#include
+typedef uint32_t crypto_uint32;
+
+#define select ed25519_select
diff --git a/plugin/auth_ed25519/crypto_uint64.h b/plugin/auth_ed25519/crypto_uint64.h
new file mode 100644
index 0000000000000..029c68191ab5e
--- /dev/null
+++ b/plugin/auth_ed25519/crypto_uint64.h
@@ -0,0 +1,5 @@
+#include
+#include
+typedef uint64_t crypto_uint64;
+
+#define select ed25519_select
diff --git a/plugin/auth_ed25519/crypto_verify.h b/plugin/auth_ed25519/crypto_verify.h
new file mode 100644
index 0000000000000..33e11b1edb051
--- /dev/null
+++ b/plugin/auth_ed25519/crypto_verify.h
@@ -0,0 +1 @@
+int crypto_verify(const unsigned char *x,const unsigned char *y);
diff --git a/plugin/auth_ed25519/crypto_verify_32.h b/plugin/auth_ed25519/crypto_verify_32.h
new file mode 100644
index 0000000000000..d8235b75c7996
--- /dev/null
+++ b/plugin/auth_ed25519/crypto_verify_32.h
@@ -0,0 +1,2 @@
+#define crypto_verify_32 crypto_verify
+int crypto_verify(const unsigned char *x,const unsigned char *y);
diff --git a/plugin/auth_ed25519/ed25519-t.c b/plugin/auth_ed25519/ed25519-t.c
new file mode 100644
index 0000000000000..7ce177a113e65
--- /dev/null
+++ b/plugin/auth_ed25519/ed25519-t.c
@@ -0,0 +1,58 @@
+/*
+ Copyright (c) 2017, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include |