1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge 10.11 into 11.0

This commit is contained in:
Marko Mäkelä
2023-10-19 08:12:16 +03:00
501 changed files with 15038 additions and 28950 deletions

View File

@ -126,8 +126,10 @@ get_make_parallel_flag
# SSL library to use.--with-ssl will select our bundled yaSSL
# implementation of SSL. --with-ssl=yes will first try system library
# then the bundled one --with-ssl=system will use the system library.
# We use bundled by default as this is guaranteed to work with Galera
SSL_LIBRARY=--with-ssl=bundled
# We normally use bundled by default as this is guaranteed to work with Galera
# However as bundled gives problem on SuSE with tls_version1.test, system
# is used
SSL_LIBRARY=--with-ssl=system
if [ "x$warning_mode" = "xpedantic" ]; then
warnings="-W -Wall -ansi -pedantic -Wno-long-long -Wno-unused -D_POSIX_SOURCE"

View File

@ -195,6 +195,15 @@ ENDIF()
OPTION(NOT_FOR_DISTRIBUTION "Allow linking with GPLv2-incompatible system libraries. Only set it you never plan to distribute the resulting binaries" OFF)
#
# Enable protection of statement's memory root after first SP/PS execution.
# Can be switched on only for debug build.
#
OPTION(WITH_PROTECT_STATEMENT_MEMROOT "Enable protection of statement's memory root after first SP/PS execution. Turned into account only for debug build" OFF)
IF (CMAKE_BUILD_TYPE MATCHES "Debug" AND WITH_PROTECT_STATEMENT_MEMROOT)
ADD_DEFINITIONS(-DPROTECT_STATEMENT_MEMROOT)
ENDIF()
INCLUDE(check_compiler_flag)
INCLUDE(check_linker_flag)

View File

@ -1639,7 +1639,7 @@ static struct my_option my_options[] =
"given sequence numbers are printed.",
&stop_pos_str, &stop_pos_str, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0,
0, 0},
{"table", 'T', "List entries for just this table (local log only).",
{"table", 'T', "List entries for just this table (affects only row events).",
&table, &table, 0, GET_STR_ALLOC, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"to-last-log", 't', "Requires -R. Will not stop at the end of the \

View File

@ -1037,35 +1037,38 @@ exit_func:
static int do_stmt_prepare(struct st_connection *cn, const char *q, int q_len)
{
/* The cn->stmt is already set. */
DBUG_ENTER("do_stmt_prepare");
if (!cn->has_thread)
return mysql_stmt_prepare(cn->stmt, q, q_len);
DBUG_RETURN(mysql_stmt_prepare(cn->stmt, q, q_len));
cn->cur_query= q;
cn->cur_query_len= q_len;
signal_connection_thd(cn, EMB_PREPARE_STMT);
wait_query_thread_done(cn);
return cn->result;
DBUG_RETURN(cn->result);
}
static int do_stmt_execute(struct st_connection *cn)
{
DBUG_ENTER("do_stmt_execute");
/* The cn->stmt is already set. */
if (!cn->has_thread)
return mysql_stmt_execute(cn->stmt);
DBUG_RETURN(mysql_stmt_execute(cn->stmt));
signal_connection_thd(cn, EMB_EXECUTE_STMT);
wait_query_thread_done(cn);
return cn->result;
DBUG_RETURN(cn->result);
}
static int do_stmt_close(struct st_connection *cn)
{
DBUG_ENTER("do_stmt_close");
/* The cn->stmt is already set. */
if (!cn->has_thread)
return mysql_stmt_close(cn->stmt);
DBUG_RETURN(mysql_stmt_close(cn->stmt));
signal_connection_thd(cn, EMB_CLOSE_STMT);
wait_query_thread_done(cn);
return cn->result;
DBUG_RETURN(cn->result);
}
@ -7967,6 +7970,7 @@ int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql)
if (!(count= mysql_warning_count(mysql)))
DBUG_RETURN(0);
DBUG_PRINT("info", ("Warnings: %ud", count));
/*
If one day we will support execution of multi-statements
@ -8422,6 +8426,7 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command,
char *query, size_t query_len, DYNAMIC_STRING *ds,
DYNAMIC_STRING *ds_warnings)
{
my_bool ignore_second_execution= 0;
MYSQL_RES *res= NULL; /* Note that here 'res' is meta data result set */
MYSQL *mysql= cn->mysql;
MYSQL_STMT *stmt;
@ -8429,6 +8434,9 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command,
DYNAMIC_STRING ds_execute_warnings;
DBUG_ENTER("run_query_stmt");
DBUG_PRINT("query", ("'%-.60s'", query));
DBUG_PRINT("info",
("disable_warnings: %d prepare_warnings_enabled: %d",
(int) disable_warnings, (int) prepare_warnings_enabled));
if (!mysql)
{
@ -8499,12 +8507,18 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command,
mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt), ds);
goto end;
}
/*
We cannot run query twice if we get prepare warnings as these will otherwise be
disabled
*/
ignore_second_execution= (prepare_warnings_enabled &&
mysql_warning_count(mysql) != 0);
}
/*
Execute the query
*/
if (do_stmt_execute(cn))
if (!ignore_second_execution && do_stmt_execute(cn))
{
handle_error(command, mysql_stmt_errno(stmt),
mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt), ds);
@ -8579,7 +8593,10 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command,
that warnings from both the prepare and execute phase are shown.
*/
if (!disable_warnings && !prepare_warnings_enabled)
{
DBUG_PRINT("info", ("warnings disabled"));
dynstr_set(&ds_prepare_warnings, NULL);
}
}
else
{
@ -8682,7 +8699,9 @@ end:
error - function will not return
*/
void run_prepare_stmt(struct st_connection *cn, struct st_command *command, const char *query, size_t query_len, DYNAMIC_STRING *ds, DYNAMIC_STRING *ds_warnings)
void run_prepare_stmt(struct st_connection *cn, struct st_command *command,
const char *query, size_t query_len, DYNAMIC_STRING *ds,
DYNAMIC_STRING *ds_warnings)
{
MYSQL *mysql= cn->mysql;
@ -8843,9 +8862,8 @@ void run_bind_stmt(struct st_connection *cn, struct st_command *command,
*/
void run_execute_stmt(struct st_connection *cn, struct st_command *command,
const char *query, size_t query_len, DYNAMIC_STRING *ds,
DYNAMIC_STRING *ds_warnings
)
const char *query, size_t query_len, DYNAMIC_STRING *ds,
DYNAMIC_STRING *ds_warnings)
{
MYSQL_RES *res= NULL; /* Note that here 'res' is meta data result set */
MYSQL *mysql= cn->mysql;

View File

@ -1,33 +0,0 @@
/*
Copyright (c) 2009 Sun Microsystems, Inc.
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-1335 USA */
/* Check stack direction (0-down, 1-up) */
int f(int *a)
{
int b;
return(&b > a)?1:0;
}
/*
Prevent compiler optimizations by calling function
through pointer.
*/
volatile int (*ptr_f)(int *) = f;
int main()
{
int a;
return ptr_f(&a);
}

View File

@ -672,25 +672,11 @@ int main()
}
" HAVE_PTHREAD_YIELD_ZERO_ARG)
IF(NOT STACK_DIRECTION)
IF(CMAKE_CROSSCOMPILING AND NOT DEFINED CMAKE_CROSSCOMPILING_EMULATOR)
MESSAGE(FATAL_ERROR
"STACK_DIRECTION is not defined. Please specify -DSTACK_DIRECTION=1 "
"or -DSTACK_DIRECTION=-1 when calling cmake.")
ELSE()
TRY_RUN(STACKDIR_RUN_RESULT STACKDIR_COMPILE_RESULT
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/cmake/stack_direction.c
)
# Test program returns 0 (down) or 1 (up).
# Convert to -1 or 1
IF(STACKDIR_RUN_RESULT EQUAL 0)
SET(STACK_DIRECTION -1 CACHE INTERNAL "Stack grows direction")
ELSE()
SET(STACK_DIRECTION 1 CACHE INTERNAL "Stack grows direction")
ENDIF()
MESSAGE(STATUS "Checking stack direction : ${STACK_DIRECTION}")
ENDIF()
IF(STACK_DIRECTION)
ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)")
SET(STACK_DIRECTION 1 CACHE INTERNAL "Stack grows direction")
ELSE()
SET(STACK_DIRECTION -1 CACHE INTERNAL "Stack grows direction")
ENDIF()
#

10
debian/rules vendored
View File

@ -51,16 +51,6 @@ ifeq (32,$(DEB_HOST_ARCH_BITS))
CMAKEFLAGS += -DPLUGIN_ROCKSDB=NO
endif
# Cross building requires stack direction instruction
ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
ifneq (,$(filter $(DEB_HOST_ARCH_CPU),alpha amd64 arm arm64 i386 ia64 m68k mips64el mipsel powerpc ppc64 ppc64el riscv64 s390x sh4 sparc64))
CMAKEFLAGS += -DSTACK_DIRECTION=-1
endif
ifneq (,$(filter $(DEB_HOST_ARCH_CPU),hppa))
CMAKEFLAGS += -DSTACK_DIRECTION=1
endif
endif
# Only attempt to build with PMEM on archs that have package libpmem-dev available
# See https://packages.debian.org/search?searchon=names&keywords=libpmem-dev
ifneq (,$(filter $(DEB_HOST_ARCH),amd64 arm64 ppc64el riscv64))

View File

@ -80,6 +80,7 @@ Street, Fifth Floor, Boston, MA 02110-1335 USA
#include <srv0start.h>
#include "trx0sys.h"
#include <buf0dblwr.h>
#include <buf0flu.h>
#include "ha_innodb.h"
#include <list>
@ -2386,10 +2387,15 @@ static bool innodb_init()
buf_flush_sync();
recv_sys.debug_free();
ut_ad(!os_aio_pending_reads());
ut_ad(!os_aio_pending_writes());
ut_d(mysql_mutex_lock(&buf_pool.flush_list_mutex));
ut_ad(!buf_pool.get_oldest_modification(0));
ut_d(mysql_mutex_unlock(&buf_pool.flush_list_mutex));
/* os_aio_pending_writes() may hold here if some write_io_callback()
did not release the slot yet. However, the page write itself must
have completed, because the buf_pool.flush_list is empty. In debug
builds, we wait for this to happen, hoping to get a hung process if
this assumption does not hold. */
ut_d(os_aio_wait_until_no_pending_writes(false));
log_sys.close_file();
if (xtrabackup_incremental)
@ -4660,7 +4666,9 @@ fail:
goto fail;
}
log_sys.create();
if (!log_sys.create()) {
goto fail;
}
/* get current checkpoint_lsn */
{
mysql_mutex_lock(&recv_sys.mutex);
@ -6030,7 +6038,9 @@ error:
}
recv_sys.create();
log_sys.create();
if (!log_sys.create()) {
goto error;
}
recv_sys.recovery_on = true;
xb_fil_io_init();

View File

@ -102,6 +102,9 @@ ${WOLFCRYPT_SRCDIR}/rsa.c
${WOLFCRYPT_SRCDIR}/sha.c
${WOLFCRYPT_SRCDIR}/sha256.c
${WOLFCRYPT_SRCDIR}/sha512.c
${WOLFCRYPT_SRCDIR}/poly1305.c
${WOLFCRYPT_SRCDIR}/chacha.c
${WOLFCRYPT_SRCDIR}/chacha20_poly1305.c
${WOLFCRYPT_SRCDIR}/wc_port.c
${WOLFCRYPT_SRCDIR}/wc_encrypt.c
${WOLFCRYPT_SRCDIR}/hash.c
@ -159,6 +162,8 @@ IF(WOLFSSL_X86_64_BUILD)
LIST(APPEND WOLFCRYPT_SOURCES
${WOLFCRYPT_SRCDIR}/aes_asm.S
${WOLFCRYPT_SRCDIR}/aes_gcm_asm.S
${WOLFCRYPT_SRCDIR}/chacha_asm.S
${WOLFCRYPT_SRCDIR}/poly1305_asm.S
${WOLFCRYPT_SRCDIR}/sha512_asm.S
${WOLFCRYPT_SRCDIR}/sha256_asm.S)
ADD_DEFINITIONS(-maes -msse4.2 -mpclmul)

View File

@ -19,11 +19,15 @@
#define HAVE_TLS_EXTENSIONS
#define HAVE_AES_ECB
#define HAVE_AESGCM
#define HAVE_CHACHA
#define HAVE_POLY1305
#define WOLFSSL_AES_COUNTER
#define NO_WOLFSSL_STUB
#define OPENSSL_ALL
#define WOLFSSL_ALLOW_TLSV10
#define NO_OLD_TIMEVAL_NAME
#define HAVE_SECURE_RENEGOTIATION
#define HAVE_EXTENDED_MASTER
/* TLSv1.3 definitions (all needed to build) */
#define WOLFSSL_TLS13

View File

@ -1020,6 +1020,12 @@ struct charset_info_st
return (coll->strnncollsp)(this, (uchar *) a, alen, (uchar *) b, blen);
}
int strnncollsp(const LEX_CSTRING &a, const LEX_CSTRING &b) const
{
return (coll->strnncollsp)(this, (uchar *) a.str, a.length,
(uchar *) b.str, b.length);
}
size_t strnxfrm(char *dst, size_t dstlen, uint nweights,
const char *src, size_t srclen, uint flags) const
{

View File

@ -53,6 +53,10 @@ typedef struct st_mem_root
unsigned short first_block_usage;
unsigned short flags;
#ifdef PROTECT_STATEMENT_MEMROOT
int read_only;
#endif
void (*error_handler)(void);
PSI_memory_key psi_key;

View File

@ -161,6 +161,7 @@ extern my_thread_id (*sf_malloc_dbug_id)(void);
typedef void (*MALLOC_SIZE_CB) (long long size, my_bool is_thread_specific);
extern void set_malloc_size_cb(MALLOC_SIZE_CB func);
extern MALLOC_SIZE_CB update_malloc_size;
/* defines when allocating data */
extern void *my_malloc(PSI_memory_key key, size_t size, myf MyFlags);
@ -898,6 +899,8 @@ extern void free_root(MEM_ROOT *root, myf MyFLAGS);
extern void set_prealloc_root(MEM_ROOT *root, char *ptr);
extern void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
size_t prealloc_size);
extern USED_MEM *get_last_memroot_block(MEM_ROOT* root);
extern void free_all_new_blocks(MEM_ROOT *root, USED_MEM *last_block);
extern void protect_root(MEM_ROOT *root, int prot);
extern char *strdup_root(MEM_ROOT *root,const char *str);
static inline char *safe_strdup_root(MEM_ROOT *root, const char *str)
@ -906,6 +909,7 @@ static inline char *safe_strdup_root(MEM_ROOT *root, const char *str)
}
extern char *strmake_root(MEM_ROOT *root,const char *str,size_t len);
extern void *memdup_root(MEM_ROOT *root,const void *str, size_t len);
extern LEX_CSTRING safe_lexcstrdup_root(MEM_ROOT *root, const LEX_CSTRING str);
extern my_bool my_compress(uchar *, size_t *, size_t *);
extern my_bool my_uncompress(uchar *, size_t , size_t *);

View File

@ -141,7 +141,6 @@ typedef unsigned long long my_ulonglong;
#define ER_WRONG_FK_OPTION_FOR_VIRTUAL_COLUMN ER_WRONG_FK_OPTION_FOR_GENERATED_COLUMN
#define ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN ER_UNSUPPORTED_ACTION_ON_GENERATED_COLUMN
#define ER_UNSUPPORTED_ENGINE_FOR_VIRTUAL_COLUMNS ER_UNSUPPORTED_ENGINE_FOR_GENERATED_COLUMNS
#define ER_QUERY_EXCEEDED_ROWS_EXAMINED_LIMIT ER_QUERY_RESULT_INCOMPLETE
#define ER_KEY_COLUMN_DOES_NOT_EXITS ER_KEY_COLUMN_DOES_NOT_EXIST
#define ER_DROP_PARTITION_NON_EXISTENT ER_PARTITION_DOES_NOT_EXIST

View File

@ -45,7 +45,7 @@ extern "C" {
/* The max key length of all supported algorithms */
#define MY_AES_MAX_KEY_LENGTH 32
#define MY_AES_CTX_SIZE 672
#define MY_AES_CTX_SIZE 1040
enum my_aes_mode {
MY_AES_ECB, MY_AES_CBC

View File

@ -1057,7 +1057,7 @@ class Client_field_extension: public Sql_alloc,
public:
Client_field_extension()
{
memset(this, 0, sizeof(*this));
memset((void*) this, 0, sizeof(*this));
}
void copy_extended_metadata(MEM_ROOT *memroot,
const Send_field_extended_metadata &src)

View File

@ -3,7 +3,7 @@
# will be skipped unless innodb is enabled
#
--disable_query_log
if (`select count(*) from information_schema.system_variables where variable_name='have_sanitizer' and global_value like "MSAN%"`)
if (`select count(*) from information_schema.system_variables where variable_name='have_sanitizer' and global_value like 'MSAN%'`)
{
SET STATEMENT sql_log_bin=0 FOR
call mtr.add_suppression("InnoDB: Trying to delete tablespace.*pending operations");

View File

@ -0,0 +1 @@
--innodb-page-size=16k

View File

@ -0,0 +1 @@
--innodb-page-size=32k

View File

@ -0,0 +1 @@
--innodb-page-size=4k

View File

@ -0,0 +1 @@
--innodb-page-size=64k

View File

@ -0,0 +1 @@
--innodb-page-size=8k

View File

@ -0,0 +1,9 @@
--source include/have_compress.inc
# Test that the system is using the default/standard bzip library.
# If not, we have to skip the test as the compression lengths displayed
# in the test will not match the results from used compression library.
if (`select length(COMPRESS(space(5000))) != 33`) {
skip Test skipped as standard bzip is needed;
}

View File

@ -1,4 +1,4 @@
if (`select convert(@@version_compile_os using latin1) LIKE 'Linux' = 0`)
if (`select @@version_compile_os not LIKE 'Linux%'`)
{
skip Need Linux;
}

View File

@ -5,15 +5,15 @@
# need to change topology after they have sourced include/rpl_init.inc
#
# This file sets up variables needed by include/rpl_sync.inc and many
# other replication scripts in the include/ directory. It also issues
# other replication scripts in the include/ directory. It also issues
# CHANGE MASTER on all servers where the configuration changes from
# what it was before. It does not issue START SLAVE (use
# what it was before. It does not issue START SLAVE (use
# include/rpl_start_slaves.inc for that).
#
# Note: it is not currently possible to change the number of servers
# after the rpl_init.inc, without first calling rpl_end.inc. So the
# test has to set $rpl_server_count to the total number of servers
# that the test uses, before it sources include/rpl_init.inc. After
# that the test uses, before it sources include/rpl_init.inc. After
# that, $rpl_server_count must not change until after next time the
# test sources include/rpl_end.inc.
#
@ -37,7 +37,7 @@
# By default, CHANGE MASTER is executed with MASTER_LOG_FILE set
# to the name of the last binlog file on the master (retrieved by
# executing SHOW MASTER STATUS). This variable can be set to
# specify another filename. This variable should be a
# specify another filename. This variable should be a
# comma-separated list of the following form:
#
# SERVER_NUMBER_1:FILE_NAME_1,SERVER_NUMBER_2:FILE_NAME_2,...
@ -45,7 +45,7 @@
# Before CHANGE MASTER is executed on server N, this script checks
# if $rpl_master_log_file contains the text N:FILE_NAME. If it
# does, then MASTER_LOG_FILE is set to FILE_NAME. Otherwise,
# MASTER_LOG_FILE is set to the last binlog on the master. For
# MASTER_LOG_FILE is set to the last binlog on the master. For
# example, to specify that server_1 should start replicate from
# master-bin.000007 and server_5 should start replicate from
# master-bin.012345, do:
@ -53,9 +53,9 @@
#
# $rpl_master_log_pos
# By default, CHANGE MASTER is executed without specifying the
# MASTER_LOG_POS parameter. This variable can be set to set a
# specific position. It has the same form as $rpl_master_log_file
# (see above). For example, to specify that server_3 should start
# MASTER_LOG_POS parameter. This variable can be set to set a
# specific position. It has the same form as $rpl_master_log_file
# (see above). For example, to specify that server_3 should start
# replicate from position 4711 of its master, do:
# --let $rpl_master_log_pos= 3:4711
#
@ -72,7 +72,7 @@
# include/rpl_stop_slaves.inc
# include/rpl_end.inc
#
# $rpl_server_count_length:
# $rpl_server_count_length
# Set to LENGTH($rpl_server_count). So if $rpl_server_count < 10,
# then $rpl_server_count_length = 1; if 10 <= $rpl_server_count <
# 100, then $rpl_server_count_length = 2, etc.
@ -83,12 +83,12 @@
# server N is a slave, then the N'th number is the master of server
# N. If server N is not a slave, then the N'th number is just spaces
# (so in fact it is not a number). For example, if $rpl_topology is
# '1->2,2->3,3->1,2->4,5->6', then $rpl_master_list is '3122 6'.
# '1->2,2->3,3->1,2->4,5->6', then $rpl_master_list is '3122 5'.
#
# $rpl_sync_chain_dirty
# This variable is set to 1. This tells include/rpl_sync.inc to
# This variable is set to 1. This tells include/rpl_sync.inc to
# compute a new value for $rpl_sync_chain next time that
# include/rpl_sync.inc is sourced. See
# include/rpl_sync.inc is sourced. See
# include/rpl_generate_sync_chain.inc and include/rpl_sync.inc for
# details.
@ -124,7 +124,7 @@ if ($rpl_master_list == '')
if ($rpl_debug)
{
--echo \$rpl_server_count='$rpl_server_count'
--echo \$rpl_server_count_length='$rpl_server_count_length'
--echo old \$rpl_server_count_length='$rpl_server_count_length'
--echo new \$rpl_topology='$_rpl_topology'
--echo old \$rpl_master_list='$rpl_master_list'
--echo old \$rpl_sync_chain='$rpl_sync_chain'
@ -210,6 +210,10 @@ if (!$rpl_skip_change_master)
--let $rpl_connection_name= server_$_rpl_master
--source include/rpl_connection.inc
--let $_rpl_master_log_file= query_get_value(SHOW MASTER STATUS, File, 1)
if ($rpl_debug)
{
--echo "\$rpl_master_log_file parameter not set for the master: $_rpl_master, use the latest binlog file by executing SHOW MASTER STATUS."
}
}
# Change connection.
--let $rpl_connection_name= server_$_rpl_server
@ -224,6 +228,10 @@ if (!$rpl_skip_change_master)
if (!$_rpl_master_log_pos_index)
{
--let $_rpl_master_log_pos=
if ($rpl_debug)
{
--echo "\$rpl_master_log_pos parameter not set for the master: $_rpl_master. Set log position to empty."
}
}
if ($rpl_master_log_file)
{

View File

@ -5,7 +5,7 @@
# This script is normally used internally by rpl_init.inc and
# master-slave.inc, but it can also be used in test cases that need to
# create more connections or re-create connections after disconnect.
#
# Default ports SERVER_MYPORT_[1,2] are set by rpl_init.inc.
#
# ==== Usage ====
#

View File

@ -103,11 +103,9 @@ while ($_rpl_server)
--connection default
--let $_rpl_server= $rpl_server_count
--let $_rpl_one= _1
while ($_rpl_server)
{
--disconnect server_$_rpl_server
--disconnect server_$_rpl_server$_rpl_one
--dec $_rpl_server
}

View File

@ -1,7 +1,7 @@
# ==== Purpose ====
#
# Execute a .inc file once for each server that was configured as a
# slave by rpl_init.inc
# slave by rpl_init.inc, for example start_slave.inc or stop_slave.inc file.
#
#
# ==== Usage ====
@ -14,6 +14,20 @@
# $rpl_source_file
# The file that will be sourced.
#
# $rpl_server_count
# The number of servers to configure. If this is not set, the largest
# number in $rpl_topology will be used.
# This parameter is obtained from rpl_init.inc.
#
# $rpl_master_list
# This parameter is calculated from within rpl_init.inc.
#
# $rpl_server_count_length
# Set to LENGTH($rpl_server_count). So if $rpl_server_count < 10,
# then $rpl_server_count_length = 1; if 10 <= $rpl_server_count <
# 100, then $rpl_server_count_length = 2, etc.
# This parameter is calculated from within rpl_change_topology.inc.
#
# $rpl_debug
# See include/rpl_init.inc

View File

@ -3,18 +3,16 @@
# Set up replication on several servers in a specified topology.
#
# By default, this script does the following:
# - Creates the connections server_1, server_2, ..., server_N, as
# well as extra connections server_1_1, server_2_1, ...,
# server_N_1. server_I and server_I_1 are connections to the same
# server.
# - Verifies that @@server_id of all servers are different.
# - Creates the connections server_1, server_2, ..., server_N.
# - Calls RESET MASTER, RESET SLAVE, USE test, CHANGE MASTER, START SLAVE.
# - Sets the connection to server_1 before exiting.
# With $rpl_check_server_ids parameter, the script does the following:
# - Verifies that @@server_id of all servers are different.
#
# ==== Usage ====
#
# 1. If you are going to use more than two servers, create
# rpl_test.cfg with the following contents:
# rpl_test.cnf with the following contents:
#
# !include ../my.cnf
# [mysqld.1]
@ -34,8 +32,9 @@
#
# (It is allowed, but not required, to configure SERVER_MYPORT_1
# and SERVER_MYPORT_2 too. If these variables are not set, the
# variables MASTER_MYPORT and SLAVE_MYPORT, configured in the
# default my.cnf used by the rpl suite, are used instead.)
# variables MASTER_MYPORT and SLAVE_MYPORT are used instead.
# These variables are configured in the rpl_1slave_base.cnf,
# that is used in the default my.cnf, which is used by the rpl suite.)
#
# 2. Execute the following near the top of the test:
#
@ -147,18 +146,15 @@ if (!$rpl_debug)
}
# Create two connections to each server; reset master/slave, select
# Create connection to the server; reset master/slave, select
# database, set autoinc variables.
--let $_rpl_server= $rpl_server_count
--let $_rpl_one= _1
while ($_rpl_server)
{
# Connect.
--let $rpl_server_number= $_rpl_server
--let $rpl_connection_name= server_$_rpl_server
--source include/rpl_connect.inc
--let $rpl_connection_name= server_$_rpl_server$_rpl_one
--source include/rpl_connect.inc
# Configure server.
--let $rpl_connection_name= server_$_rpl_server
@ -203,7 +199,7 @@ if ($rpl_check_server_ids)
while ($_rpl_server2)
{
--let $assert_text= Servers $_rpl_server and $_rpl_server2 should have different @@server_id
--let $assert_condition= [$_rpl_server:SELECT @@server_id AS i, i, 1] != [$_rpl_server2:SELECT @@server_id AS i, i, 1]
--let $assert_cond= [SELECT @@server_id AS i, i, 1] != $_rpl_server
--source include/assert.inc
--dec $_rpl_server2
@ -212,18 +208,30 @@ if ($rpl_check_server_ids)
}
}
# $rpl_master_list must be set so that include/rpl_change_topology.inc
# knows which servers are initialized and not.
if ($rpl_debug)
{
--echo ---- Check the topology and call CHANGE MASTER ----
}
# $rpl_master_list must be set so that include/rpl_change_topology.inc and later
# include/rpl_for_each_slave.inc knows which servers are initialized and not.
--let $rpl_master_list= `SELECT REPEAT('x', $rpl_server_count * LENGTH($rpl_server_count))`
--source include/rpl_change_topology.inc
if (!$rpl_skip_start_slave)
{
if ($rpl_debug)
{
--echo ---- Start slaves ----
}
--source include/rpl_start_slaves.inc
}
if ($rpl_debug)
{
--echo ---- Set connection to the server_1 ----
}
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc

View File

@ -72,11 +72,6 @@ if (!$_rpl_server_number)
--source include/rpl_connection.inc
--enable_reconnect
--let $_rpl_one= _1
--let $rpl_connection_name= server_$rpl_server_number$_rpl_one
--source include/rpl_connection.inc
--enable_reconnect
if ($rpl_debug)
{
--echo ---- Wait for reconnect and disable reconnect on all connections ----
@ -122,11 +117,5 @@ if (!$_rpl_server_number)
--source include/wait_until_connected_again.inc
--disable_reconnect
--let $rpl_connection_name= server_$rpl_server_number$_rpl_one
--source include/rpl_connection.inc
--source include/wait_until_connected_again.inc
--disable_reconnect
--let $include_filename= rpl_reconnect.inc
--source include/end_include_file.inc

View File

@ -19,7 +19,7 @@
#
# $slave_timeout
# Set the timeout when waiting for slave threads to stop and
# start, respectively. See include/wait_for_slave_param.inc
# start, respectively. See include/wait_for_slave_param.inc
--let $include_filename= rpl_start_slaves.inc

View File

@ -14,13 +14,14 @@
#
# Parameters:
# $slave_timeout
# See include/wait_for_slave_param.inc
# Timeout used when waiting for the slave IO thread to start.
# See include/wait_for_slave_param.inc.
#
# $rpl_allow_error
# By default, this file fails if there is an error in the IO
# thread. However, the IO thread can recover and reconnect after
# certain errors. If such an error is expected, can set
# $rpl_allow_error=1. This will prevent this file from failing if
# thread. However, the IO thread can recover and reconnect after
# certain errors. If such an error is expected, can set
# $rpl_allow_error=1. This will prevent this file from failing if
# there is an error in the IO thread.
#
# $rpl_debug

View File

@ -11,6 +11,7 @@
#
# Parameters:
# $slave_timeout
# Timeout used when waiting for the slave SQL thread to start.
# See include/wait_for_slave_param.inc
#
# $rpl_debug
@ -25,7 +26,7 @@ let $slave_param= Slave_SQL_Running;
let $slave_param_value= Yes;
# Unfortunately, the slave sql thread sets Slave_SQL_Running=Yes
# *before* it clears Last_SQL_Errno. So we have to allow errors in
# *before* it clears Last_SQL_Errno. So we have to allow errors in
# the SQL thread here.
#--let $slave_error_param= Last_SQL_Errno

View File

@ -12,6 +12,7 @@
#
# Parameters:
# $slave_timeout
# Timeout used when waiting for the slave threads to start.
# See include/wait_for_slave_param.inc
#
# $rpl_debug

View File

@ -94,7 +94,7 @@ py
import subprocess,shlex,time
valg=subprocess.Popen(shlex.split("""valgrind --tool=memcheck --show-reachable=yes --leak-check=yes --num-callers=16 --quiet --suppressions=valgrind.supp --vgdb-error=0 {exe} {args} --loose-wait-for-pos-timeout=1500"""))
time.sleep(2)
gdb.execute("target remote | /usr/lib64/valgrind/../../bin/vgdb --pid=" + str(valg.pid))
gdb.execute("target remote | vgdb --pid=" + str(valg.pid))
EEE
pre => sub {
my $debug_libraries_path= "/usr/lib/debug";

View File

@ -20,9 +20,10 @@ package My::Platform;
use strict;
use File::Basename;
use File::Path;
use Carp;
use base qw(Exporter);
our @EXPORT= qw(IS_CYGWIN IS_WINDOWS IS_WIN32PERL IS_AIX
our @EXPORT= qw(IS_CYGWIN IS_MSYS IS_WINDOWS IS_WIN32PERL IS_AIX
native_path posix_path mixed_path
check_socket_path_length process_alive open_for_append);
@ -33,9 +34,15 @@ BEGIN {
die "Could not execute 'cygpath': $!";
}
eval 'sub IS_CYGWIN { 1 }';
eval 'sub IS_MSYS { 0 }';
}
elsif ($^O eq "msys") {
eval 'sub IS_CYGWIN { 1 }';
eval 'sub IS_MSYS { 1 }';
}
else {
eval 'sub IS_CYGWIN { 0 }';
eval 'sub IS_MSYS { 0 }';
}
if ($^O eq "MSWin32") {
eval 'sub IS_WIN32PERL { 1 }';
@ -95,8 +102,13 @@ sub mixed_path {
sub native_path {
my ($path)= @_;
$path=~ s/\//\\/g
if (IS_CYGWIN or IS_WIN32PERL);
if (IS_CYGWIN) {
# \\\\ protects against 2 expansions (just for the case)
$path=~ s/\/+|\\+/\\\\\\\\/g;
}
elsif (IS_WINDOWS) {
$path=~ s/\/+/\\/g;
}
return $path;
}
@ -219,4 +231,69 @@ sub open_for_append
}
sub check_cygwin_subshell
{
# Only pipe (or sh-expansion) is fed to /bin/sh
my $out= `echo %comspec%|cat`;
return ($out =~ /\bcmd.exe\b/) ? 0 : 1;
}
sub install_shell_wrapper()
{
system("rm -f /bin/sh.exe") and die $!;
my $wrapper= <<'EOF';
#!/bin/bash
if [[ -n "$MTR_PERL" && "$1" = "-c" ]]; then
shift
exec $(cygpath -m "$COMSPEC") /C "$@"
fi
exec /bin/bash "$@"
EOF
open(OUT, '>', "/bin/sh") or die "/bin/sh: $!\n";
print OUT $wrapper;
close(OUT);
system("chmod +x /bin/sh") and die $!;
print "Cygwin subshell wrapper /bin/sh was installed, please restart MTR!\n";
exit(0);
}
sub uninstall_shell_wrapper()
{
system("rm -f /bin/sh") and die $!;
system("cp /bin/bash.exe /bin/sh.exe") and die $!;
}
sub cygwin_subshell_fix
{
my ($opt_name, $opt_value)= @_;
if ($opt_name ne "cygwin-subshell-fix") {
confess "Wrong option name: ${opt_name}";
}
if ($opt_value eq "do") {
if (check_cygwin_subshell()) {
install_shell_wrapper();
} else {
print "Cygwin subshell fix was already installed, skipping...\n";
}
} elsif ($opt_value eq "remove") {
if (check_cygwin_subshell()) {
print "Cygwin subshell fix was already uninstalled, skipping...\n";
} else {
uninstall_shell_wrapper();
}
} else {
die "Wrong --cygwin-subshell-fix value: ${opt_value} (expected do/remove)";
}
}
sub options
{
if (IS_CYGWIN) {
return ('cygwin-subshell-fix=s' => \&cygwin_subshell_fix);
} else {
return ();
}
}
1;

View File

@ -102,7 +102,7 @@ else
# Find the safe process binary or script
sub find_bin {
if (IS_WIN32PERL or IS_CYGWIN)
if (IS_WINDOWS)
{
# Use my_safe_process.exe
my $exe= my_find_bin($bindir, ["lib/My/SafeProcess", "My/SafeProcess"],

View File

@ -111,7 +111,7 @@ sub read_test {
$serialized =~ s/\\([0-9a-fA-F]{2})/chr(hex($1))/eg;
my $test= Storable::thaw($serialized);
use Data::Dumper;
die "wrong class (hack attempt?): ".ref($test)."\n".Dumper(\$test, $serialized)
confess "Not My::Test: ". ref($test). "\n". Dumper(\$test, $serialized)
unless ref($test) eq 'My::Test';
resfile_from_test($test) if $::opt_resfile;
return $test;

View File

@ -48,6 +48,7 @@ our $timestamp= 0;
our $timediff= 0;
our $name;
our $verbose;
# TODO: no option for that? Why is it different from $verbose?
our $verbose_restart= 0;
our $timer= 1;
our $tests_total;

View File

@ -3072,6 +3072,40 @@ drop table t1;
# End of 10.5 tests
#
#
# MDEV-32449 Server crashes in Alter_info::add_stat_drop_index upon CREATE TABLE
#
CREATE TABLE t1 (
`altcol1` blob DEFAULT '',
KEY `altcol1` (`altcol1`(2300))
) ROW_FORMAT=PAGE, ENGINE=Aria;
ALTER TABLE t1 ADD FOREIGN KEY h (`altcol1`) REFERENCES t1 (`altcol1`) ON UPDATE SET DEFAULT, ALGORITHM=COPY;
Warnings:
Note 1071 Specified key was too long; max key length is 2300 bytes
create or replace table t2 like t1;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`altcol1` blob DEFAULT '',
KEY `altcol1` (`altcol1`(2300)),
KEY `h` (`altcol1`(2300))
) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 ROW_FORMAT=PAGE
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`altcol1` blob DEFAULT '',
KEY `altcol1` (`altcol1`(2300))
) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 ROW_FORMAT=PAGE
drop table t1,t2;
# Another test for MDEV-32449
CREATE TABLE t1 (a POINT, b POINT, KEY(a)) ENGINE=Aria;
ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES t (b);
CREATE TEMPORARY TABLE t2 LIKE t1;
DROP TEMPORARY TABLE t2;
DROP TABLE t1;
#
# End of 10.6 tests
#
#
# MDEV-26767 Server crashes when rename table and alter storage engine
#
alter table txxx engine=innodb, rename to tyyy;

View File

@ -2369,6 +2369,32 @@ drop table t1;
--echo # End of 10.5 tests
--echo #
--echo #
--echo # MDEV-32449 Server crashes in Alter_info::add_stat_drop_index upon CREATE TABLE
--echo #
CREATE TABLE t1 (
`altcol1` blob DEFAULT '',
KEY `altcol1` (`altcol1`(2300))
) ROW_FORMAT=PAGE, ENGINE=Aria;
ALTER TABLE t1 ADD FOREIGN KEY h (`altcol1`) REFERENCES t1 (`altcol1`) ON UPDATE SET DEFAULT, ALGORITHM=COPY;
create or replace table t2 like t1;
show create table t1;
show create table t2;
drop table t1,t2;
--echo # Another test for MDEV-32449
CREATE TABLE t1 (a POINT, b POINT, KEY(a)) ENGINE=Aria;
ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES t (b);
CREATE TEMPORARY TABLE t2 LIKE t1;
DROP TEMPORARY TABLE t2;
DROP TABLE t1;
--echo #
--echo # End of 10.6 tests
--echo #
--echo #
--echo # MDEV-26767 Server crashes when rename table and alter storage engine
--echo #

View File

@ -71,3 +71,351 @@ optimize table t1 extended;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'extended' at line 1
drop table t1;
End of 5.0 tests
#
# Test analyze of text column (not yet supported)
#
set optimizer_use_condition_selectivity=4;
set histogram_type='single_prec_hb';
set histogram_size=255;
create table t1 (a int not null, t tinytext, tx text);
insert into t1 select seq+1, repeat('X',seq*5), repeat('X',seq*10) from seq_0_to_50;
insert into t1 select seq+100, repeat('X',5), "" from seq_1_to_10;
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze Warning Engine-independent statistics are not collected for column 't'
test.t1 analyze Warning Engine-independent statistics are not collected for column 'tx'
test.t1 analyze status OK
explain select count(*) from t1 where t='XXXXXX';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 61 Using where
select column_name, min_value, max_value, hist_size from mysql.column_stats where table_name='t1';
column_name min_value max_value hist_size
a 1 110 255
drop table t1;
set use_stat_tables=default;
set histogram_type=default;
set histogram_size=default;
#
# MDEV-31957 Concurrent ALTER and ANALYZE collecting statistics can
# result in stale statistical data
#
CREATE TABLE t1 (a INT, b VARCHAR(128));
INSERT INTO t1 SELECT seq, CONCAT('s',seq) FROM seq_1_to_100;
connect con1,localhost,root,,;
ALTER TABLE t1 MODIFY b BLOB;
connection default;
ANALYZE TABLE t1 PERSISTENT FOR ALL;
connection con1;
ANALYZE TABLE t1 PERSISTENT FOR ALL;
connection default;
disconnect con1;
select db_name,table_name,column_name from mysql.column_stats;
db_name table_name column_name
test t1 a
drop table t1;
#
# Testing swapping columns
#
create or replace table t1 (a int primary key, b varchar(100), c varchar(100), d varchar(100)) engine=innodb;
insert into t1 select seq, repeat('b',seq),repeat('c',mod(seq,5)), repeat('d',mod(seq,10)) from seq_1_to_100;
ANALYZE TABLE t1 PERSISTENT FOR ALL;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
db_name table_name column_name avg_length
test t1 a 4.0000
test t1 b 50.5000
test t1 c 2.0000
test t1 d 4.5000
alter table t1 change b c varchar(200), change c b varchar(200);
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
db_name table_name column_name avg_length
test t1 a 4.0000
test t1 b 2.0000
test t1 c 50.5000
test t1 d 4.5000
alter table t1 change b c varchar(200), change c d varchar(200), change d b varchar(200) ;
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
db_name table_name column_name avg_length
test t1 a 4.0000
test t1 b 4.5000
test t1 c 2.0000
test t1 d 50.5000
alter table t1 change b c varchar(200), change c d varchar(200), change d e varchar(200) ;
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
db_name table_name column_name avg_length
test t1 a 4.0000
test t1 c 4.5000
test t1 d 2.0000
test t1 e 50.5000
alter table t1 change e d varchar(200), drop column d;
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
db_name table_name column_name avg_length
test t1 a 4.0000
test t1 c 4.5000
test t1 d 50.5000
# Test having non existing column in column_stats
insert into mysql.column_stats (db_name,table_name,column_name) values ("test","t1","b");
alter table t1 change c d varchar(200), change d b varchar(200);
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
db_name table_name column_name avg_length
test t1 a 4.0000
test t1 b 50.5000
test t1 d 4.5000
# Test having a conflicting temporary name
insert into mysql.column_stats (db_name,table_name,column_name) values ("test","t1",concat("#sql_tmp_name#1",char(0)));
alter table t1 change d b varchar(200), change b d varchar(200);
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
db_name table_name column_name avg_length
test t1 a 4.0000
test t1 b 4.5000
test t1 d 50.5000
drop table t1;
truncate table mysql.column_stats;
create or replace table t1 (a int primary key, b varchar(100), c varchar(100), d varchar(100)) engine=myisam;
insert into t1 select seq, repeat('b',seq),repeat('c',mod(seq,5)), repeat('d',mod(seq,10)) from seq_1_to_100;
ANALYZE TABLE t1 PERSISTENT FOR ALL;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
db_name table_name column_name avg_length
test t1 a 4.0000
test t1 b 50.5000
test t1 c 2.0000
test t1 d 4.5000
alter table t1 change b c varchar(200), change c b varchar(200);
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
db_name table_name column_name avg_length
test t1 a 4.0000
test t1 d 4.5000
analyze table t1 persistent for columns(b,c) indexes all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status Table is already up to date
alter table t1 change b c varchar(200), change c d varchar(200), change d b varchar(200) ;
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
db_name table_name column_name avg_length
test t1 a 4.0000
test t1 b 50.5000
test t1 c 2.0000
analyze table t1 persistent for columns(d) indexes all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status Table is already up to date
alter table t1 change b c varchar(200), change c d varchar(200), change d e varchar(200) ;
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
db_name table_name column_name avg_length
test t1 a 4.0000
test t1 c 50.5000
test t1 d 2.0000
test t1 e 50.5000
alter table t1 change e d varchar(200), drop column d;
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
db_name table_name column_name avg_length
test t1 a 4.0000
test t1 c 50.5000
test t1 d 50.5000
drop table t1;
truncate table mysql.column_stats;
create table t1 (a int, b blob, unique(b)) engine= innodb;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze Warning Engine-independent statistics are not collected for column 'b'
test.t1 analyze status OK
select column_name from mysql.column_stats where table_name = 't1';
column_name
a
drop table t1;
create table t1 (a int, b blob, c int generated always as (length(b)) virtual) engine= innodb;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze Warning Engine-independent statistics are not collected for column 'b'
test.t1 analyze status OK
select column_name from mysql.column_stats where table_name = 't1';
column_name
a
c
drop table t1;
CREATE or replace TABLE t1 (a INT, b CHAR(8));
ANALYZE TABLE t1 PERSISTENT FOR ALL;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status Table is already up to date
ALTER TABLE t1 CHANGE b c INT, ORDER BY b;
SELECT db_name, table_name, column_name FROM mysql.column_stats where table_name = 't1';
db_name table_name column_name
test t1 a
test t1 c
drop table t1;
CREATE or replace TABLE t1 (a INT, b CHAR(8));
ANALYZE TABLE t1 PERSISTENT FOR ALL;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status Table is already up to date
ALTER TABLE t1 RENAME COLUMN b to c, ALGORITHM=COPY;
SELECT db_name, table_name, column_name FROM mysql.column_stats where table_name = 't1';
db_name table_name column_name
test t1 a
test t1 c
drop table t1;
#
# Testing swapping indexes
#
create or replace table t1 (a int primary key, b varchar(100), c varchar(100), d varchar(100), index (b), index(c), index(d,b)) engine=innodb;
insert into t1 select seq, repeat('b',seq),repeat('c',mod(seq,5)), repeat('d',mod(seq,10)) from seq_1_to_100;
ANALYZE TABLE t1 PERSISTENT FOR ALL;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
select * from mysql.index_stats order by index_name, prefix_arity;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
test t1 b 1 1.0000
test t1 b 2 1.0000
test t1 c 1 20.0000
test t1 c 2 1.0000
test t1 d 1 10.0000
test t1 d 2 1.0000
test t1 d 3 1.0000
alter table t1 rename index b to c, rename index c to d, rename index d to b;
select * from mysql.index_stats order by index_name;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
test t1 b 1 10.0000
test t1 b 2 1.0000
test t1 b 3 1.0000
test t1 c 1 1.0000
test t1 c 2 1.0000
test t1 d 1 20.0000
test t1 d 2 1.0000
alter table t1 rename index b to c, rename index c to d, rename index d to e;
select * from mysql.index_stats order by index_name, prefix_arity;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
test t1 c 1 10.0000
test t1 c 2 1.0000
test t1 c 3 1.0000
test t1 d 1 1.0000
test t1 d 2 1.0000
test t1 e 1 20.0000
test t1 e 2 1.0000
alter table t1 rename index e to b;
alter table t1 change b c varchar(200), change c d varchar(200), change d e varchar(200) ;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`c` varchar(200) DEFAULT NULL,
`d` varchar(200) DEFAULT NULL,
`e` varchar(200) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `d` (`c`),
KEY `b` (`d`),
KEY `c` (`e`,`c`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
select * from mysql.index_stats order by index_name, prefix_arity;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
test t1 b 1 20.0000
test t1 b 2 1.0000
test t1 c 1 10.0000
test t1 c 2 1.0000
test t1 c 3 1.0000
test t1 d 1 1.0000
test t1 d 2 1.0000
# Test having a conflicting temporary name
insert into mysql.index_stats (db_name,table_name,index_name,prefix_arity) values ("test","t1",concat("#sql_tmp_name#1",char(0)),1);
alter table t1 rename index c to d, rename index d to c;
select * from mysql.index_stats order by index_name, prefix_arity;
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
test t1 b 1 20.0000
test t1 b 2 1.0000
test t1 c 1 1.0000
test t1 c 2 1.0000
test t1 d 1 10.0000
test t1 d 2 1.0000
test t1 d 3 1.0000
drop table t1;
select * from mysql.index_stats order by index_name, prefix_arity;
db_name table_name index_name prefix_arity avg_frequency
#
# Test of adding key that replaces foreign key
#
CREATE TABLE t1 (aaaa INT, b INT, KEY(b), FOREIGN KEY(aaaa) REFERENCES t1(b)) ENGINE=InnoDB;
ANALYZE TABLE t1 PERSISTENT FOR ALL;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT index_name FROM mysql.index_stats WHERE table_name = 't1' order by index_name;
index_name
aaaa
b
ALTER TABLE t1 ADD KEY idx(aaaa);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`aaaa` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
KEY `b` (`b`),
KEY `idx` (`aaaa`),
CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`aaaa`) REFERENCES `t1` (`b`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT index_name FROM mysql.index_stats WHERE table_name = 't1' order by index_name;
index_name
b
truncate table mysql.index_stats;
ANALYZE TABLE t1 PERSISTENT FOR ALL;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT index_name FROM mysql.index_stats WHERE table_name = 't1' order by index_name;
index_name
b
idx
ALTER TABLE t1 DROP KEY idx;
ERROR HY000: Cannot drop index 'idx': needed in a foreign key constraint
DROP TABLE t1;
#
# Check index rename where name is not changed
#
create or replace table t1 (a int primary key, b int, c int, key b (b,c));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` int(11) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `b` (`b`,`c`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status Table is already up to date
select * from mysql.index_stats where table_name= "t1";
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
test t1 b 1 NULL
test t1 b 2 NULL
alter ignore table t1 rename key `b` to b, LOCK=shared;
select * from mysql.index_stats where table_name= "t1";
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
test t1 b 1 NULL
test t1 b 2 NULL
alter ignore table t1 rename key `b` to `B`, LOCK=shared;
select * from mysql.index_stats where table_name= "t1";
db_name table_name index_name prefix_arity avg_frequency
test t1 PRIMARY 1 1.0000
test t1 B 1 NULL
test t1 B 2 NULL
drop table t1;
#
# End of 10.6 tests
#

View File

@ -1,3 +1,6 @@
--source include/have_sequence.inc
--source include/have_innodb.inc
#
# Bug #10901 Analyze Table on new table destroys table
# This is minimal test case to get error
@ -87,3 +90,185 @@ optimize table t1 extended;
drop table t1;
--echo End of 5.0 tests
--echo #
--echo # Test analyze of text column (not yet supported)
--echo #
set optimizer_use_condition_selectivity=4;
set histogram_type='single_prec_hb';
set histogram_size=255;
create table t1 (a int not null, t tinytext, tx text);
insert into t1 select seq+1, repeat('X',seq*5), repeat('X',seq*10) from seq_0_to_50;
insert into t1 select seq+100, repeat('X',5), "" from seq_1_to_10;
analyze table t1;
explain select count(*) from t1 where t='XXXXXX';
select column_name, min_value, max_value, hist_size from mysql.column_stats where table_name='t1';
drop table t1;
set use_stat_tables=default;
set histogram_type=default;
set histogram_size=default;
--echo #
--echo # MDEV-31957 Concurrent ALTER and ANALYZE collecting statistics can
--echo # result in stale statistical data
--echo #
CREATE TABLE t1 (a INT, b VARCHAR(128));
INSERT INTO t1 SELECT seq, CONCAT('s',seq) FROM seq_1_to_100;
# We have to disable query log as the ANALYZE TABLE can be run in different
# order. The important thing is what is finally in column_stats
--disable_result_log
--connect (con1,localhost,root,,)
--send ALTER TABLE t1 MODIFY b BLOB
--connection default
ANALYZE TABLE t1 PERSISTENT FOR ALL;
--connection con1
--reap
ANALYZE TABLE t1 PERSISTENT FOR ALL;
--connection default
--disconnect con1
--enable_result_log
select db_name,table_name,column_name from mysql.column_stats;
drop table t1;
--echo #
--echo # Testing swapping columns
--echo #
create or replace table t1 (a int primary key, b varchar(100), c varchar(100), d varchar(100)) engine=innodb;
insert into t1 select seq, repeat('b',seq),repeat('c',mod(seq,5)), repeat('d',mod(seq,10)) from seq_1_to_100;
ANALYZE TABLE t1 PERSISTENT FOR ALL;
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
alter table t1 change b c varchar(200), change c b varchar(200);
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
alter table t1 change b c varchar(200), change c d varchar(200), change d b varchar(200) ;
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
alter table t1 change b c varchar(200), change c d varchar(200), change d e varchar(200) ;
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
alter table t1 change e d varchar(200), drop column d;
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
--echo # Test having non existing column in column_stats
insert into mysql.column_stats (db_name,table_name,column_name) values ("test","t1","b");
alter table t1 change c d varchar(200), change d b varchar(200);
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
--echo # Test having a conflicting temporary name
insert into mysql.column_stats (db_name,table_name,column_name) values ("test","t1",concat("#sql_tmp_name#1",char(0)));
alter table t1 change d b varchar(200), change b d varchar(200);
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
drop table t1;
truncate table mysql.column_stats;
create or replace table t1 (a int primary key, b varchar(100), c varchar(100), d varchar(100)) engine=myisam;
insert into t1 select seq, repeat('b',seq),repeat('c',mod(seq,5)), repeat('d',mod(seq,10)) from seq_1_to_100;
ANALYZE TABLE t1 PERSISTENT FOR ALL;
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
alter table t1 change b c varchar(200), change c b varchar(200);
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
analyze table t1 persistent for columns(b,c) indexes all;
alter table t1 change b c varchar(200), change c d varchar(200), change d b varchar(200) ;
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
analyze table t1 persistent for columns(d) indexes all;
alter table t1 change b c varchar(200), change c d varchar(200), change d e varchar(200) ;
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
alter table t1 change e d varchar(200), drop column d;
select db_name,table_name,column_name,avg_length from mysql.column_stats order by column_name;
drop table t1;
truncate table mysql.column_stats;
create table t1 (a int, b blob, unique(b)) engine= innodb;
analyze table t1 persistent for all;
select column_name from mysql.column_stats where table_name = 't1';
drop table t1;
create table t1 (a int, b blob, c int generated always as (length(b)) virtual) engine= innodb;
analyze table t1 persistent for all;
select column_name from mysql.column_stats where table_name = 't1';
drop table t1;
CREATE or replace TABLE t1 (a INT, b CHAR(8));
ANALYZE TABLE t1 PERSISTENT FOR ALL;
ALTER TABLE t1 CHANGE b c INT, ORDER BY b;
SELECT db_name, table_name, column_name FROM mysql.column_stats where table_name = 't1';
drop table t1;
CREATE or replace TABLE t1 (a INT, b CHAR(8));
ANALYZE TABLE t1 PERSISTENT FOR ALL;
ALTER TABLE t1 RENAME COLUMN b to c, ALGORITHM=COPY;
SELECT db_name, table_name, column_name FROM mysql.column_stats where table_name = 't1';
drop table t1;
--echo #
--echo # Testing swapping indexes
--echo #
create or replace table t1 (a int primary key, b varchar(100), c varchar(100), d varchar(100), index (b), index(c), index(d,b)) engine=innodb;
insert into t1 select seq, repeat('b',seq),repeat('c',mod(seq,5)), repeat('d',mod(seq,10)) from seq_1_to_100;
ANALYZE TABLE t1 PERSISTENT FOR ALL;
select * from mysql.index_stats order by index_name, prefix_arity;
alter table t1 rename index b to c, rename index c to d, rename index d to b;
select * from mysql.index_stats order by index_name;
alter table t1 rename index b to c, rename index c to d, rename index d to e;
select * from mysql.index_stats order by index_name, prefix_arity;
alter table t1 rename index e to b;
alter table t1 change b c varchar(200), change c d varchar(200), change d e varchar(200) ;
show create table t1;
select * from mysql.index_stats order by index_name, prefix_arity;
--echo # Test having a conflicting temporary name
insert into mysql.index_stats (db_name,table_name,index_name,prefix_arity) values ("test","t1",concat("#sql_tmp_name#1",char(0)),1);
alter table t1 rename index c to d, rename index d to c;
select * from mysql.index_stats order by index_name, prefix_arity;
drop table t1;
select * from mysql.index_stats order by index_name, prefix_arity;
--echo #
--echo # Test of adding key that replaces foreign key
--echo #
CREATE TABLE t1 (aaaa INT, b INT, KEY(b), FOREIGN KEY(aaaa) REFERENCES t1(b)) ENGINE=InnoDB;
ANALYZE TABLE t1 PERSISTENT FOR ALL;
SELECT index_name FROM mysql.index_stats WHERE table_name = 't1' order by index_name;
ALTER TABLE t1 ADD KEY idx(aaaa);
SHOW CREATE TABLE t1;
SELECT index_name FROM mysql.index_stats WHERE table_name = 't1' order by index_name;
truncate table mysql.index_stats;
ANALYZE TABLE t1 PERSISTENT FOR ALL;
SELECT index_name FROM mysql.index_stats WHERE table_name = 't1' order by index_name;
--error ER_DROP_INDEX_FK
ALTER TABLE t1 DROP KEY idx;
DROP TABLE t1;
--echo #
--echo # Check index rename where name is not changed
--echo #
create or replace table t1 (a int primary key, b int, c int, key b (b,c));
show create table t1;
analyze table t1 persistent for all;
select * from mysql.index_stats where table_name= "t1";
alter ignore table t1 rename key `b` to b, LOCK=shared;
select * from mysql.index_stats where table_name= "t1";
alter ignore table t1 rename key `b` to `B`, LOCK=shared;
select * from mysql.index_stats where table_name= "t1";
drop table t1;
--echo #
--echo # End of 10.6 tests
--echo #

View File

@ -70,7 +70,8 @@ TRUNCATE TABLE t1;
SET column_compression_zlib_level= 1;
INSERT INTO t1 VALUES(REPEAT('ab', 1000));
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN('Column_compressions', 'Column_decompressions');
SELECT DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
# This is is using < as DATA_LENGTH produces different results on s390x-ubuntu-2004
SELECT DATA_LENGTH < 100 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
TRUNCATE TABLE t1;
SET column_compression_zlib_level= 9;

View File

@ -133,9 +133,9 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN('Column_c
VARIABLE_NAME VARIABLE_VALUE
COLUMN_COMPRESSIONS 3
COLUMN_DECOMPRESSIONS 12
SELECT DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DATA_LENGTH
40
SELECT DATA_LENGTH < 100 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DATA_LENGTH < 100
1
TRUNCATE TABLE t1;
SET column_compression_zlib_level= 9;
INSERT INTO t1 VALUES(REPEAT('ab', 1000));
@ -348,9 +348,9 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN('Column_c
VARIABLE_NAME VARIABLE_VALUE
COLUMN_COMPRESSIONS 3
COLUMN_DECOMPRESSIONS 12
SELECT DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DATA_LENGTH
40
SELECT DATA_LENGTH < 100 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DATA_LENGTH < 100
1
TRUNCATE TABLE t1;
SET column_compression_zlib_level= 9;
INSERT INTO t1 VALUES(REPEAT('ab', 1000));
@ -563,9 +563,9 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN('Column_c
VARIABLE_NAME VARIABLE_VALUE
COLUMN_COMPRESSIONS 3
COLUMN_DECOMPRESSIONS 12
SELECT DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DATA_LENGTH
40
SELECT DATA_LENGTH < 100 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DATA_LENGTH < 100
1
TRUNCATE TABLE t1;
SET column_compression_zlib_level= 9;
INSERT INTO t1 VALUES(REPEAT('ab', 1000));
@ -778,9 +778,9 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN('Column_c
VARIABLE_NAME VARIABLE_VALUE
COLUMN_COMPRESSIONS 3
COLUMN_DECOMPRESSIONS 12
SELECT DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DATA_LENGTH
40
SELECT DATA_LENGTH < 100 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DATA_LENGTH < 100
1
TRUNCATE TABLE t1;
SET column_compression_zlib_level= 9;
INSERT INTO t1 VALUES(REPEAT('ab', 1000));
@ -993,9 +993,9 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN('Column_c
VARIABLE_NAME VARIABLE_VALUE
COLUMN_COMPRESSIONS 3
COLUMN_DECOMPRESSIONS 12
SELECT DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DATA_LENGTH
60
SELECT DATA_LENGTH < 100 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DATA_LENGTH < 100
1
TRUNCATE TABLE t1;
SET column_compression_zlib_level= 9;
INSERT INTO t1 VALUES(REPEAT('ab', 1000));
@ -1209,9 +1209,9 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME IN('Column_c
VARIABLE_NAME VARIABLE_VALUE
COLUMN_COMPRESSIONS 3
COLUMN_DECOMPRESSIONS 12
SELECT DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DATA_LENGTH
36
SELECT DATA_LENGTH < 100 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DATA_LENGTH < 100
1
TRUNCATE TABLE t1;
SET column_compression_zlib_level= 9;
INSERT INTO t1 VALUES(REPEAT('ab', 1000));

View File

@ -1,5 +1,6 @@
--source include/have_innodb.inc
--source include/have_csv.inc
--source include/have_normal_bzip.inc
let $MYSQLD_DATADIR= `select @@datadir`;

View File

@ -1,5 +1,6 @@
--source include/have_innodb.inc
--source include/master-slave.inc
--source include/have_normal_bzip.inc
--let $engine_type= myisam
--let $engine_type2= innodb

View File

@ -4,6 +4,8 @@ insert into t1 values ('000000000001'),('000000000002');
explain select * from t1 where id=000000000001;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY PRIMARY 12 NULL 2 Using where; Using index
Warnings:
Note 1105 Cannot use key `PRIMARY` part[0] for lookup: `test`.`t1`.`id` of type `char` = "1" of type `bigint`
select * from t1 where id=000000000001;
id
000000000001

View File

@ -606,6 +606,8 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT * FROM t1 WHERE s2='a' COLLATE latin1_german1_ci;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL s2 NULL NULL NULL 10 Using where
Warnings:
Note 1105 Cannot use key `s2` part[0] for lookup: `test`.`t1`.`s2` of collation `latin1_swedish_ci` = "'a' collate latin1_german1_ci" of collation `latin1_german1_ci`
EXPLAIN SELECT * FROM t1 WHERE s1 BETWEEN 'a' AND 'b' COLLATE latin1_german1_ci;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range s1 s1 11 NULL 2 Using index condition

View File

@ -355,97 +355,6 @@ ERROR 42S01: Table 't1' already exists
DROP TABLE t2;
DROP TABLE t1;
#
# Bug#54332 Deadlock with two connections doing LOCK TABLE+INSERT DELAYED
#
# This test is not supposed to work under --ps-protocol since
# INSERT DELAYED doesn't work under LOCK TABLES with this protocol.
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a INT);
CREATE TABLE t3 (a INT);
# Test 1: Using LOCK TABLE
connect con1, localhost, root;
LOCK TABLE t1 WRITE;
connection default;
LOCK TABLE t2 WRITE;
# Sending:
INSERT DELAYED INTO t1 VALUES (1);
connection con1;
# Wait until INSERT DELAYED is blocked on table 't1'.
INSERT DELAYED INTO t2 VALUES (1);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
UNLOCK TABLES;
connection default;
# Reaping: INSERT DELAYED INTO t1 VALUES (1)
UNLOCK TABLES;
# Test 2: Using ALTER TABLE
START TRANSACTION;
SELECT * FROM t1 WHERE a=0;
a
connection con1;
# Sending:
ALTER TABLE t1 MODIFY a INT UNSIGNED;;
connection default;
# Wait until ALTER TABLE is blocked on table 't1'.
INSERT DELAYED INTO t1 VALUES (3);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
connection con1;
# Reaping: ALTER TABLE t1 COMMENT 'test'
# Test 3: Using RENAME TABLE
connection default;
START TRANSACTION;
INSERT INTO t2 VALUES (1);
connection con1;
# Sending:
RENAME TABLE t1 to t5, t2 to t4;
connection default;
# Wait until RENAME TABLE is blocked on table 't1'.
INSERT DELAYED INTO t1 VALUES (4);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
connection con1;
# Reaping: RENAME TABLE t1 to t5, t2 to t4
connection default;
# Reverting the renames
RENAME TABLE t5 to t1, t4 to t2;
# Test 4: Two INSERT DELAYED on the same table
START TRANSACTION;
INSERT INTO t2 VALUES (1);
connect con2, localhost, root;
LOCK TABLE t1 WRITE, t2 WRITE;
connection con1;
# Wait until LOCK TABLE is blocked on table 't2'.
INSERT DELAYED INTO t1 VALUES (5);
connection default;
# Wait until INSERT DELAYED is blocked on table 't1'.
INSERT DELAYED INTO t1 VALUES (6);
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
connection con2;
# Reaping: LOCK TABLE t1 WRITE, t2 WRITE
UNLOCK TABLES;
connection con1;
# Reaping: INSERT DELAYED INTO t1 VALUES (5)
connection default;
# Test 5: LOCK TABLES + INSERT DELAYED in one connection.
# This test has triggered some asserts in metadata locking
# subsystem at some point in time..
LOCK TABLE t1 WRITE;
INSERT DELAYED INTO t2 VALUES (7);
UNLOCK TABLES;
SET AUTOCOMMIT= 0;
LOCK TABLE t1 WRITE;
INSERT DELAYED INTO t2 VALUES (8);
UNLOCK TABLES;
SET AUTOCOMMIT= 1;
connection con2;
disconnect con2;
connection con1;
disconnect con1;
connection default;
DROP TABLE t1, t2, t3;
#
# Test for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables".
#
connect con1,localhost,root,,;

View File

@ -408,6 +408,9 @@ DROP TABLE t2;
DROP TABLE t1;
# The following test is disabled as it fails randomly
if (0)
{
--echo #
--echo # Bug#54332 Deadlock with two connections doing LOCK TABLE+INSERT DELAYED
--echo #
@ -566,6 +569,7 @@ connection default;
DROP TABLE t1, t2, t3;
--enable_ps_protocol
--enable_view_protocol
}
--echo #
--echo # Test for bug #56251 "Deadlock with INSERT DELAYED and MERGE tables".

View File

@ -1,4 +1,5 @@
-- source include/have_compress.inc
-- source include/have_normal_bzip.inc
#
# Test for compress and uncompress functions:
#

View File

@ -912,7 +912,8 @@ a IN (CAST(1 AS SIGNED), CAST(1 AS UNSIGNED))
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (bigint)
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
Note 1105 DBUG: found a mix of UINT and SINT
Note 1105 DBUG: types_compatible=yes bisect=yes
SELECT a IN (CAST(1 AS SIGNED), CAST(1 AS UNSIGNED),NULL) FROM t1;
a IN (CAST(1 AS SIGNED), CAST(1 AS UNSIGNED),NULL)
Warnings:
@ -950,7 +951,8 @@ a NOT IN (CAST(1 AS SIGNED), CAST(1 AS UNSIGNED))
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (bigint)
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
Note 1105 DBUG: found a mix of UINT and SINT
Note 1105 DBUG: types_compatible=yes bisect=yes
SELECT a NOT IN (CAST(1 AS SIGNED), CAST(1 AS UNSIGNED),NULL) FROM t1;
a NOT IN (CAST(1 AS SIGNED), CAST(1 AS UNSIGNED),NULL)
Warnings:
@ -1624,7 +1626,8 @@ a b
Warnings:
Note 1105 DBUG: [0] arg=1 handler=0 (bigint)
Note 1105 DBUG: [1] arg=2 handler=1 (decimal)
Note 1105 DBUG: types_compatible=no bisect=no
Note 1105 DBUG: found a mix of UINT and SINT
Note 1105 DBUG: types_compatible=yes bisect=no
DROP TABLE t1;
#
# MDEV-11554 Wrong result for CASE on a mixture of signed and unsigned expressions

View File

@ -935,6 +935,43 @@ Warning 1292 Truncated incorrect DECIMAL value: '0x'
# End of 10.4 tests
#
#
# Start of 10.5 tests
#
#
# MDEV-31303: Key not used
#
CREATE TABLE `a` (
`id` bigint AUTO_INCREMENT PRIMARY KEY,
`c1` bigint unsigned,
KEY (`c1`)
);
INSERT INTO `a` VALUES (1,9223382399205928659),(2,9223384207280813348),
(3,9223385953115437234),(4,9223387250780556749),(5,9223387354282558788),
(6,9223387603870501596),(7,9223389270813433667),(8,9223389903231468827),
(9,9223390280789586779),(10,9223391591398222899),(11,9223391875473564350),
(12,9223393152250049433),(13,9223393939696790223),(14,9223394417225350415),
(15,9223397646397141015),(16,9223398025879291243),(17,9223399038671098072),
(18,9223399534968874556),(19,9223400449518009285),(20,9223400860292643549),
(21,9223400940692256924),(22,9223401073791948119),(23,9223402820804649616),
(24,9223403470951992681),(25,9223405581879567267),(26,9223405754978563829),
(27,9223405972966828221), (28, 9223372036854775808), (29, 9223372036854775807) ;
explain SELECT c1 FROM a WHERE c1 IN ( 1, 9223372036854775807 );
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE a range c1 c1 9 NULL 2 Using where; Using index
explain SELECT c1 FROM a WHERE c1 IN ( 1, 9223372036854775808 );
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE a range c1 c1 9 NULL 2 Using where; Using index
SELECT c1 FROM a WHERE c1 IN ( 1, 9223372036854775807 );
c1
9223372036854775807
SELECT c1 FROM a WHERE c1 IN ( 1, 9223372036854775808 );
c1
9223372036854775808
drop table `a`;
#
# End of 10.5 tests
#
#
# MDEV-29662 same values in `IN` set vs equal comparison produces
# the different performance
#

View File

@ -712,6 +712,40 @@ SELECT ('0x',1) IN ((0,1),(1,1));
--echo # End of 10.4 tests
--echo #
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-31303: Key not used
--echo #
CREATE TABLE `a` (
`id` bigint AUTO_INCREMENT PRIMARY KEY,
`c1` bigint unsigned,
KEY (`c1`)
);
INSERT INTO `a` VALUES (1,9223382399205928659),(2,9223384207280813348),
(3,9223385953115437234),(4,9223387250780556749),(5,9223387354282558788),
(6,9223387603870501596),(7,9223389270813433667),(8,9223389903231468827),
(9,9223390280789586779),(10,9223391591398222899),(11,9223391875473564350),
(12,9223393152250049433),(13,9223393939696790223),(14,9223394417225350415),
(15,9223397646397141015),(16,9223398025879291243),(17,9223399038671098072),
(18,9223399534968874556),(19,9223400449518009285),(20,9223400860292643549),
(21,9223400940692256924),(22,9223401073791948119),(23,9223402820804649616),
(24,9223403470951992681),(25,9223405581879567267),(26,9223405754978563829),
(27,9223405972966828221), (28, 9223372036854775808), (29, 9223372036854775807) ;
explain SELECT c1 FROM a WHERE c1 IN ( 1, 9223372036854775807 );
explain SELECT c1 FROM a WHERE c1 IN ( 1, 9223372036854775808 );
SELECT c1 FROM a WHERE c1 IN ( 1, 9223372036854775807 );
SELECT c1 FROM a WHERE c1 IN ( 1, 9223372036854775808 );
drop table `a`;
--echo #
--echo # End of 10.5 tests
--echo #
--echo #
--echo # MDEV-29662 same values in `IN` set vs equal comparison produces
--echo # the different performance
@ -845,4 +879,3 @@ drop table t1;
--echo #
--echo # End of 10.6 tests
--echo #

View File

@ -906,5 +906,54 @@ SELECT * FROM t HAVING f = 'foo';
f
DROP TABLE t;
#
# MDEV-29731 Crash when HAVING in a correlated subquery references
# columns in the outer query
#
CREATE TABLE t (a INT, b INT);
SELECT 1 FROM t
WHERE b = (SELECT 1 FROM t GROUP BY a HAVING b = a+1);
1
DROP TABLE t;
CREATE TABLE t (a INT, b INT, c INT);
SELECT 1 FROM t
WHERE (b,c) = (SELECT 1,1 FROM t GROUP BY a HAVING b = a+1 and c = a-1);
1
DROP TABLE t;
CREATE TABLE t (a TEXT, b INT UNIQUE);
SELECT 1 FROM t
WHERE b IN (SELECT 1 FROM t
GROUP BY '', a
HAVING (CASE b WHEN 1 +'' THEN 3 ELSE a END)
ORDER BY b)
GROUP BY b HAVING b = 1;
1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: ''
DROP TABLE t;
CREATE TABLE t (a INT, b CHAR KEY UNIQUE);
CREATE VIEW v AS SELECT * FROM t WHERE a LIKE '' GROUP BY b HAVING a > a;
SELECT * FROM v AS v1 NATURAL JOIN v AS v5 NATURAL JOIN v
WHERE a LIKE '' AND b IN (SELECT a FROM t
WHERE a LIKE ''
GROUP BY a
HAVING b LIKE (b < +1 OR a > 1) >= b);
a b
DROP VIEW v;
DROP TABLE t;
EXECUTE IMMEDIATE 'SELECT LEAD(c) OVER (ORDER BY c)
FROM (SELECT 0 AS c) AS a NATURAL JOIN (SELECT 0 AS c) AS b;';
LEAD(c) OVER (ORDER BY c)
NULL
CREATE TABLE t (a INT);
UPDATE t SET a = ''
WHERE 1 IN (SELECT * FROM
(SELECT * FROM
(SELECT * FROM t AS v5 NATURAL JOIN t AS v4 NATURAL JOIN t) AS v3
NATURAL JOIN t
GROUP BY a) AS v2
WHERE (0, a) IN ((0,-1),(+1,0))
ORDER BY 1+AVG(a) OVER (ORDER BY a)) ORDER BY a;
DROP TABLE t;
#
# End of 10.4 tests
#

View File

@ -950,8 +950,53 @@ DROP TABLE t1,t2;
CREATE TABLE t (f VARCHAR(512));
INSERT INTO t VALUES ('a'),('b');
SELECT * FROM t HAVING f = 'foo';
DROP TABLE t;
# Cleanup
--echo #
--echo # MDEV-29731 Crash when HAVING in a correlated subquery references
--echo # columns in the outer query
--echo #
CREATE TABLE t (a INT, b INT);
SELECT 1 FROM t
WHERE b = (SELECT 1 FROM t GROUP BY a HAVING b = a+1);
DROP TABLE t;
CREATE TABLE t (a INT, b INT, c INT);
SELECT 1 FROM t
WHERE (b,c) = (SELECT 1,1 FROM t GROUP BY a HAVING b = a+1 and c = a-1);
DROP TABLE t;
CREATE TABLE t (a TEXT, b INT UNIQUE);
SELECT 1 FROM t
WHERE b IN (SELECT 1 FROM t
GROUP BY '', a
HAVING (CASE b WHEN 1 +'' THEN 3 ELSE a END)
ORDER BY b)
GROUP BY b HAVING b = 1;
DROP TABLE t;
CREATE TABLE t (a INT, b CHAR KEY UNIQUE);
CREATE VIEW v AS SELECT * FROM t WHERE a LIKE '' GROUP BY b HAVING a > a;
SELECT * FROM v AS v1 NATURAL JOIN v AS v5 NATURAL JOIN v
WHERE a LIKE '' AND b IN (SELECT a FROM t
WHERE a LIKE ''
GROUP BY a
HAVING b LIKE (b < +1 OR a > 1) >= b);
DROP VIEW v;
DROP TABLE t;
EXECUTE IMMEDIATE 'SELECT LEAD(c) OVER (ORDER BY c)
FROM (SELECT 0 AS c) AS a NATURAL JOIN (SELECT 0 AS c) AS b;';
CREATE TABLE t (a INT);
UPDATE t SET a = ''
WHERE 1 IN (SELECT * FROM
(SELECT * FROM
(SELECT * FROM t AS v5 NATURAL JOIN t AS v4 NATURAL JOIN t) AS v3
NATURAL JOIN t
GROUP BY a) AS v2
WHERE (0, a) IN ((0,-1),(+1,0))
ORDER BY 1+AVG(a) OVER (ORDER BY a)) ORDER BY a;
DROP TABLE t;
--echo #

View File

@ -1804,7 +1804,7 @@ sum(t3.b)
show status like "handler_read%";
Variable_name Value
Handler_read_first 0
Handler_read_key 13
Handler_read_key 4
Handler_read_last 0
Handler_read_next 5
Handler_read_prev 0
@ -1819,7 +1819,7 @@ sum(t3.b)
show status like "handler_read%";
Variable_name Value
Handler_read_first 0
Handler_read_key 7
Handler_read_key 4
Handler_read_last 0
Handler_read_next 5
Handler_read_prev 0

View File

@ -1811,7 +1811,7 @@ sum(t3.b)
show status like "handler_read%";
Variable_name Value
Handler_read_first 0
Handler_read_key 13
Handler_read_key 4
Handler_read_last 0
Handler_read_next 5
Handler_read_prev 0
@ -1826,7 +1826,7 @@ sum(t3.b)
show status like "handler_read%";
Variable_name Value
Handler_read_first 0
Handler_read_key 7
Handler_read_key 4
Handler_read_last 0
Handler_read_next 5
Handler_read_prev 0

View File

@ -13,6 +13,7 @@ Variable_name Value
log_slow_admin_statements ON
log_slow_disabled_statements sp
log_slow_filter admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
log_slow_max_warnings 10
log_slow_min_examined_row_limit 0
log_slow_query ON
log_slow_query_file $PATH/mysqld-slow.log
@ -56,15 +57,15 @@ start_time timestamp(6) NO current_timestamp(6) on update current_timestamp(6)
user_host mediumtext NO NULL
query_time time(6) NO NULL
lock_time time(6) NO NULL
rows_sent int(11) NO NULL
rows_examined int(11) NO NULL
rows_sent bigint(20) unsigned NO NULL
rows_examined bigint(20) unsigned NO NULL
db varchar(512) NO NULL
last_insert_id int(11) NO NULL
insert_id int(11) NO NULL
server_id int(10) unsigned NO NULL
sql_text mediumtext NO NULL
thread_id bigint(21) unsigned NO NULL
rows_affected int(11) NO NULL
rows_affected bigint(20) unsigned NO NULL
flush slow logs;
set long_query_time=0.1;
set log_slow_filter='';
@ -137,3 +138,54 @@ drop table t;
#
# End of 10.3 tests
#
#
# MDEV-31742: incorrect examined rows in case of stored function usage
#
CREATE TABLE `tab_MDEV_30820` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`NAME_F` varchar(50) DEFAULT NULL,
PRIMARY KEY (`ID`)
);
CREATE TABLE `tab2` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`TAB1_ID` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
);
CREATE FUNCTION `get_zero`() RETURNS int(11)
BEGIN
RETURN(0) ;
END
//
for i in 1..100 do insert into tab_MDEV_30820 values (i,'qwerty'); end for ; //
for i in 1..1000 do insert into tab2 values (i,i+300); end for ; //
SET @old_slow_query_log= @@global.slow_query_log;
SET @old_log_output= @@global.log_output;
SET @old_long_query_time= @@long_query_time;
SET GLOBAL log_output= "TABLE";
SET GLOBAL slow_query_log= ON;
SET SESSION slow_query_log=ON;
SET SESSION long_query_time= 0;
SELECT 0 as zero, (SELECT ID FROM tab2 where tab2.TAB1_ID =
tab_MDEV_30820.ID ORDER BY 1 LIMIT 1 ) AS F1 FROM tab_MDEV_30820 ORDER BY 2 DESC LIMIT 2;
zero F1
0 NULL
0 NULL
SELECT get_zero() as zero, (SELECT ID FROM tab2 where tab2.TAB1_ID =
tab_MDEV_30820.ID ORDER BY 1 LIMIT 1) AS F1 FROM tab_MDEV_30820 ORDER BY 2 DESC LIMIT 2;
zero F1
0 NULL
0 NULL
# should be the same rows_examined
SELECT rows_examined FROM mysql.slow_log WHERE sql_text LIKE '%SELECT%tab_MDEV_30820%';
rows_examined
100202
100202
SET @@long_query_time= @old_long_query_time;
SET @@global.log_output= @old_log_output;
SET @@global.slow_query_log= @old_slow_query_log;
SET SESSION slow_query_log=default;
drop table tab_MDEV_30820, tab2;
drop function get_zero;
#
# End of 10.4 tests
#

View File

@ -122,3 +122,70 @@ drop table t;
--echo #
--echo # End of 10.3 tests
--echo #
--echo #
--echo # MDEV-31742: incorrect examined rows in case of stored function usage
--echo #
CREATE TABLE `tab_MDEV_30820` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`NAME_F` varchar(50) DEFAULT NULL,
PRIMARY KEY (`ID`)
);
CREATE TABLE `tab2` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`TAB1_ID` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
);
--disable_ps2_protocol
--disable_view_protocol
--delimiter //
CREATE FUNCTION `get_zero`() RETURNS int(11)
BEGIN
RETURN(0) ;
END
//
for i in 1..100 do insert into tab_MDEV_30820 values (i,'qwerty'); end for ; //
for i in 1..1000 do insert into tab2 values (i,i+300); end for ; //
--delimiter ;
SET @old_slow_query_log= @@global.slow_query_log;
SET @old_log_output= @@global.log_output;
SET @old_long_query_time= @@long_query_time;
SET GLOBAL log_output= "TABLE";
SET GLOBAL slow_query_log= ON;
SET SESSION slow_query_log=ON;
SET SESSION long_query_time= 0;
SELECT 0 as zero, (SELECT ID FROM tab2 where tab2.TAB1_ID =
tab_MDEV_30820.ID ORDER BY 1 LIMIT 1 ) AS F1 FROM tab_MDEV_30820 ORDER BY 2 DESC LIMIT 2;
SELECT get_zero() as zero, (SELECT ID FROM tab2 where tab2.TAB1_ID =
tab_MDEV_30820.ID ORDER BY 1 LIMIT 1) AS F1 FROM tab_MDEV_30820 ORDER BY 2 DESC LIMIT 2;
--echo # should be the same rows_examined
SELECT rows_examined FROM mysql.slow_log WHERE sql_text LIKE '%SELECT%tab_MDEV_30820%';
## Reset to initial values
SET @@long_query_time= @old_long_query_time;
SET @@global.log_output= @old_log_output;
SET @@global.slow_query_log= @old_slow_query_log;
SET SESSION slow_query_log=default;
drop table tab_MDEV_30820, tab2;
drop function get_zero;
--enable_view_protocol
--enable_ps2_protocol
--echo #
--echo # End of 10.4 tests
--echo #

View File

@ -230,6 +230,91 @@ sql_text
[slow] DEALLOCATE PREPARE stmt
[slow] DROP SEQUENCE s4
#
# Start of 10.6 tests
#
#
# MDEV-32203 Raise notes when an index cannot be used on data type
# mismatch
#
CREATE TABLE t1 (a VARCHAR(10), KEY(a));
insert into t1 select seq from seq_0_to_31;
SET note_verbosity=all;
SET log_slow_verbosity=all;
SET global log_output='FILE';
set @org_slow_query_log_file=@@global.slow_query_log_file;
set global slow_query_log_file='MYSQLTEST_VARDIR/tmp/log_slow_debug-1.log';
FLUSH SLOW LOGS;
SELECT * FROM t1 WHERE a=10;
a
10
Warnings:
Note 1105 Cannot use key `a` part[0] for lookup: `test`.`t1`.`a` of type `varchar` = "10" of type `int`
EXPLAIN SELECT * FROM t1 WHERE a=10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index a a 13 NULL 32 Using where; Using index
Warnings:
Note 1105 Cannot use key `a` part[0] for lookup: `test`.`t1`.`a` of type `varchar` = "10" of type `int`
FOUND 2 /# Warnings/ in log_slow_debug-1.log
FOUND 1 /# Note.*Cannot use key.*varchar.*10.*int/ in log_slow_debug-1.log
set global slow_query_log_file='MYSQLTEST_VARDIR/tmp/log_slow_debug-2.log';
SET note_verbosity="explain";
FLUSH SLOW LOGS;
EXPLAIN SELECT * FROM t1 WHERE a=10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index a a 13 NULL 32 Using where; Using index
Warnings:
Note 1105 Cannot use key `a` part[0] for lookup: `test`.`t1`.`a` of type `varchar` = "10" of type `int`
FOUND 1 /# Warnings/ in log_slow_debug-2.log
FOUND 1 /# Note.*Cannot use key.*varchar.*10.*int/ in log_slow_debug-2.log
set global slow_query_log_file='MYSQLTEST_VARDIR/tmp/log_slow_debug-3.log';
SET log_slow_verbosity=replace(@@log_slow_verbosity, "warnings", "");
SET log_slow_verbosity=replace(@@log_slow_verbosity, "full", "");
SET note_verbosity=all;
FLUSH SLOW LOGS;
SELECT * FROM t1 WHERE a=10;
a
10
Warnings:
Note 1105 Cannot use key `a` part[0] for lookup: `test`.`t1`.`a` of type `varchar` = "10" of type `int`
EXPLAIN SELECT * FROM t1 WHERE a=10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index a a 13 NULL 32 Using where; Using index
Warnings:
Note 1105 Cannot use key `a` part[0] for lookup: `test`.`t1`.`a` of type `varchar` = "10" of type `int`
NOT FOUND /# Warnings/ in log_slow_debug-3.log
NOT FOUND /# Note.*Cannot use key.*varchar.*10.*int/ in log_slow_debug-3.log
set @@global.slow_query_log_file= @org_slow_query_log_file;
DROP TABLE t1;
#
# MDEV-30820: slow log Rows_examined out of range
#
CREATE TABLE `tab_MDEV_30820` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`A` int(11),
PRIMARY KEY(ID)
);
insert into tab_MDEV_30820 values (null, 0),(null, 0);
SET @old_slow_query_log= @@global.slow_query_log;
SET @old_log_output= @@global.log_output;
SET @old_long_query_time= @@long_query_time;
SET @old_dbug= @@GLOBAL.debug_dbug;
SET GLOBAL log_output= "TABLE";
SET GLOBAL slow_query_log= ON;
SET SESSION long_query_time= 0;
SET GLOBAL debug_dbug="+d,debug_huge_number_of_examined_rows";
SELECT * FROM tab_MDEV_30820 ORDER BY 1;
ID A
1 0
2 0
SET GLOBAL debug_dbug=@old_dbug;
SET @@long_query_time= @old_long_query_time;
SET @@global.log_output= @old_log_output;
SET @@global.slow_query_log= @old_slow_query_log;
drop table tab_MDEV_30820;
#
# End of 10.4 test
#
#
# Clean up
#
SET SESSION debug_dbug=@saved_dbug;

View File

@ -1,4 +1,5 @@
-- source include/have_debug.inc
-- source include/have_sequence.inc
SET @org_slow_query_log= @@global.slow_query_log;
SET @org_log_output= @@global.log_output;
@ -82,6 +83,108 @@ TRUNCATE TABLE mysql.slow_log;
--source include/log_slow_debug_common.inc
CALL show_slow_log();
--echo #
--echo # Start of 10.6 tests
--echo #
--echo #
--echo # MDEV-32203 Raise notes when an index cannot be used on data type
--echo # mismatch
--echo #
CREATE TABLE t1 (a VARCHAR(10), KEY(a));
insert into t1 select seq from seq_0_to_31;
SET note_verbosity=all;
SET log_slow_verbosity=all;
SET global log_output='FILE';
set @org_slow_query_log_file=@@global.slow_query_log_file;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval set global slow_query_log_file='$MYSQLTEST_VARDIR/tmp/log_slow_debug-1.log';
FLUSH SLOW LOGS;
--disable_ps_protocol
SELECT * FROM t1 WHERE a=10;
EXPLAIN SELECT * FROM t1 WHERE a=10;
--enable_ps_protocol
--let SEARCH_FILE = `SELECT @@slow_query_log_file`
--let SEARCH_PATTERN=# Warnings
--source include/search_pattern_in_file.inc
--let SEARCH_PATTERN= # Note.*Cannot use key.*varchar.*10.*int
--source include/search_pattern_in_file.inc
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval set global slow_query_log_file='$MYSQLTEST_VARDIR/tmp/log_slow_debug-2.log';
SET note_verbosity="explain";
FLUSH SLOW LOGS;
EXPLAIN SELECT * FROM t1 WHERE a=10;
--let SEARCH_FILE = `SELECT @@slow_query_log_file`
--let SEARCH_PATTERN=# Warnings
--source include/search_pattern_in_file.inc
--let SEARCH_PATTERN= # Note.*Cannot use key.*varchar.*10.*int
--source include/search_pattern_in_file.inc
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval set global slow_query_log_file='$MYSQLTEST_VARDIR/tmp/log_slow_debug-3.log';
SET log_slow_verbosity=replace(@@log_slow_verbosity, "warnings", "");
SET log_slow_verbosity=replace(@@log_slow_verbosity, "full", "");
SET note_verbosity=all;
FLUSH SLOW LOGS;
SELECT * FROM t1 WHERE a=10;
EXPLAIN SELECT * FROM t1 WHERE a=10;
--let SEARCH_FILE = `SELECT @@slow_query_log_file`
--let SEARCH_PATTERN=# Warnings
--source include/search_pattern_in_file.inc
--let SEARCH_PATTERN= # Note.*Cannot use key.*varchar.*10.*int
--source include/search_pattern_in_file.inc
set @@global.slow_query_log_file= @org_slow_query_log_file;
--remove_file $MYSQLTEST_VARDIR/tmp/log_slow_debug-1.log
--remove_file $MYSQLTEST_VARDIR/tmp/log_slow_debug-2.log
--remove_file $MYSQLTEST_VARDIR/tmp/log_slow_debug-3.log
DROP TABLE t1;
--echo #
--echo # MDEV-30820: slow log Rows_examined out of range
--echo #
CREATE TABLE `tab_MDEV_30820` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`A` int(11),
PRIMARY KEY(ID)
);
insert into tab_MDEV_30820 values (null, 0),(null, 0);
SET @old_slow_query_log= @@global.slow_query_log;
SET @old_log_output= @@global.log_output;
SET @old_long_query_time= @@long_query_time;
SET @old_dbug= @@GLOBAL.debug_dbug;
SET GLOBAL log_output= "TABLE";
SET GLOBAL slow_query_log= ON;
SET SESSION long_query_time= 0;
SET GLOBAL debug_dbug="+d,debug_huge_number_of_examined_rows";
SELECT * FROM tab_MDEV_30820 ORDER BY 1;
SET GLOBAL debug_dbug=@old_dbug;
## Reset to initial values
SET @@long_query_time= @old_long_query_time;
SET @@global.log_output= @old_log_output;
SET @@global.slow_query_log= @old_slow_query_log;
drop table tab_MDEV_30820;
--echo #
--echo # End of 10.4 test
--echo #
--echo #
--echo # Clean up

View File

@ -73,15 +73,15 @@ slow_log CREATE TABLE `slow_log` (
`user_host` mediumtext NOT NULL,
`query_time` time(6) NOT NULL,
`lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`rows_sent` bigint(20) unsigned NOT NULL,
`rows_examined` bigint(20) unsigned NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL,
`rows_affected` int(11) NOT NULL
`rows_affected` bigint(20) unsigned NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='Slow log'
show fields from mysql.slow_log;
Field Type Null Key Default Extra
@ -89,15 +89,15 @@ start_time timestamp(6) NO current_timestamp(6) on update current_timestamp(6)
user_host mediumtext NO NULL
query_time time(6) NO NULL
lock_time time(6) NO NULL
rows_sent int(11) NO NULL
rows_examined int(11) NO NULL
rows_sent bigint(20) unsigned NO NULL
rows_examined bigint(20) unsigned NO NULL
db varchar(512) NO NULL
last_insert_id int(11) NO NULL
insert_id int(11) NO NULL
server_id int(10) unsigned NO NULL
sql_text mediumtext NO NULL
thread_id bigint(21) unsigned NO NULL
rows_affected int(11) NO NULL
rows_affected bigint(20) unsigned NO NULL
flush logs;
flush tables;
SET GLOBAL GENERAL_LOG=ON;
@ -180,15 +180,15 @@ slow_log CREATE TABLE `slow_log` (
`user_host` mediumtext NOT NULL,
`query_time` time(6) NOT NULL,
`lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`rows_sent` bigint(20) unsigned NOT NULL,
`rows_examined` bigint(20) unsigned NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL,
`rows_affected` int(11) NOT NULL
`rows_affected` bigint(20) unsigned NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='Slow log'
alter table mysql.general_log engine=myisam;
alter table mysql.slow_log engine=myisam;
@ -209,15 +209,15 @@ slow_log CREATE TABLE `slow_log` (
`user_host` mediumtext NOT NULL,
`query_time` time(6) NOT NULL,
`lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`rows_sent` bigint(20) unsigned NOT NULL,
`rows_examined` bigint(20) unsigned NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL,
`rows_affected` int(11) NOT NULL
`rows_affected` bigint(20) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='Slow log'
set global general_log='ON';
set global slow_query_log='ON';
@ -287,15 +287,15 @@ ON UPDATE CURRENT_TIMESTAMP,
`user_host` mediumtext NOT NULL,
`query_time` time(6) NOT NULL,
`lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`rows_sent` bigint(20) unsigned NOT NULL,
`rows_examined` bigint(20) unsigned NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL,
`thread_id` BIGINT(21) UNSIGNED NOT NULL,
`rows_affected` int(11) NOT NULL
`rows_affected` bigint(20) unsigned NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log';
set global general_log='ON';
set global slow_query_log='ON';
@ -580,15 +580,15 @@ CREATE TABLE `db_17876.slow_log_data` (
`user_host` mediumtext ,
`query_time` time(6) ,
`lock_time` time(6) ,
`rows_sent` int(11) ,
`rows_examined` int(11) ,
`rows_sent` bigint(20) unsigned,
`rows_examined` bigint(20) unsigned,
`db` varchar(512) default NULL,
`last_insert_id` int(11) default NULL,
`insert_id` int(11) default NULL,
`server_id` int(11) default NULL,
`sql_text` mediumtext,
`thread_id` bigint(21) unsigned default NULL,
`rows_affected` int(11) default NULL
`rows_affected` bigint(20) unsigned default NULL
);
CREATE TABLE `db_17876.general_log_data` (
`event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

View File

@ -307,15 +307,15 @@ CREATE TABLE `slow_log` (
`user_host` mediumtext NOT NULL,
`query_time` time(6) NOT NULL,
`lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`rows_sent` bigint(20) unsigned NOT NULL,
`rows_examined` bigint(20) unsigned NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL,
`thread_id` BIGINT(21) UNSIGNED NOT NULL,
`rows_affected` int(11) NOT NULL
`rows_affected` bigint(20) unsigned NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log';
set global general_log='ON';
@ -743,15 +743,15 @@ CREATE TABLE `db_17876.slow_log_data` (
`user_host` mediumtext ,
`query_time` time(6) ,
`lock_time` time(6) ,
`rows_sent` int(11) ,
`rows_examined` int(11) ,
`rows_sent` bigint(20) unsigned,
`rows_examined` bigint(20) unsigned,
`db` varchar(512) default NULL,
`last_insert_id` int(11) default NULL,
`insert_id` int(11) default NULL,
`server_id` int(11) default NULL,
`sql_text` mediumtext,
`thread_id` bigint(21) unsigned default NULL,
`rows_affected` int(11) default NULL
`rows_affected` bigint(20) unsigned default NULL
);
CREATE TABLE `db_17876.general_log_data` (

View File

@ -457,6 +457,41 @@ create table t1 (f text not null, unique (f));
insert into t1 (f) select 'f';
drop table t1;
#
# MDEV-32012 hash unique corrupts index on virtual blobs
#
create table t1 (
f1 varchar(25),
v1 mediumtext generated always as (concat('f1:', f1)) virtual,
unique key (f1) using hash,
key (v1(1000))
);
flush status;
insert ignore t1 (f1) values (9599),(94410);
show status like 'handler_read_next';
Variable_name Value
Handler_read_next 1
# the above MUST BE =1
check table t1 extended;
Table Op Msg_type Msg_text
test.t1 check status OK
update t1 set f1=100 where f1=9599;
update t1 set f1=9599 where f1=100;
check table t1 extended;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
#
# MDEV-32015 insert into an empty table fails with hash unique
#
create table t1 (f1 varchar(25), unique (f1) using hash);
insert ignore t1 (f1) values ('new york'),('virginia'),('spouse'),(null),('zqekmqpwutxnzddrbjycyo'),('nebraska'),('illinois'),('qe'),('ekmqpwut'),('arizona'),('arizona');
Warnings:
Warning 1062 Duplicate entry 'arizona' for key 'f1'
check table t1 extended;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
#
# End of 10.4 tests
#
#

View File

@ -456,6 +456,38 @@ create table t1 (f text not null, unique (f));
insert into t1 (f) select 'f';
drop table t1;
--echo #
--echo # MDEV-32012 hash unique corrupts index on virtual blobs
--echo #
create table t1 (
f1 varchar(25),
v1 mediumtext generated always as (concat('f1:', f1)) virtual,
unique key (f1) using hash,
key (v1(1000))
);
flush status;
insert ignore t1 (f1) values (9599),(94410);
# handler_read_next must be 1 below, meaning there was a hash collision above.
# if a change in the hash function causes these values not to collide anymore,
# the test must be adjusted to use some other values that collide.
# to find a collision add an assert into check_duplicate_long_entry_key()
# and run, like, insert...select * seq_from_1_to_1000000000
show status like 'handler_read_next';
--echo # the above MUST BE =1
check table t1 extended;
update t1 set f1=100 where f1=9599;
update t1 set f1=9599 where f1=100;
check table t1 extended;
drop table t1;
--echo #
--echo # MDEV-32015 insert into an empty table fails with hash unique
--echo #
create table t1 (f1 varchar(25), unique (f1) using hash);
insert ignore t1 (f1) values ('new york'),('virginia'),('spouse'),(null),('zqekmqpwutxnzddrbjycyo'),('nebraska'),('illinois'),('qe'),('ekmqpwut'),('arizona'),('arizona');
check table t1 extended;
drop table t1;
--echo #
--echo # End of 10.4 tests
--echo #

View File

@ -1,3 +1,6 @@
#
# MDEV-22722 Assertion "inited==NONE" failed in handler::ha_index_init on the slave during UPDATE
#
include/master-slave.inc
[connection master]
create table t1 (i1 int, a1 text, unique key i1 (a1)) engine=myisam;
@ -6,7 +9,21 @@ insert into t1 values (2,2);
update t1 set a1 = 'd' limit 1;
update t1 set a1 = 'd2' where i1= 2;
connection slave;
connection slave;
connection master;
drop table t1;
#
# MDEV-32093 long uniques break old->new replication
#
connection slave;
create table t1 (id int not null, b1 varchar(255) not null, b2 varchar(2550) not null, unique (id), unique key (b1,b2) using hash) default charset utf8mb3;
set global slave_exec_mode=idempotent;
binlog 'aRf2ZA8BAAAA/AAAAAABAAAAAAQAMTAuNS4xNS1NYXJpYURCLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABpF/ZkEzgNAAgAEgAEBAQEEgAA5AAEGggAAAAICAgCAAAACgoKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEEwQADQgICAoKCgFRmTlk';
binlog 'bBf2ZBMBAAAANAAAAJgHAAAAAHEAAAAAAAEABHRlc3QAAnQxAAQDDw8IBP0C4h0AeqMD4A==bBf2ZBcBAAAANAAAAMwHAAAAAHEAAAAAAAEABP/wj6QAAAEAYgEAZa6/VU0JAAAANteqUw==';
binlog 'bBf2ZBMBAAAANAAAAJgHAAAAAHEAAAAAAAEABHRlc3QAAnQxAAQDDw8IBP0C4h0AeqMD4A==bBf2ZBcBAAAANAAAAMwHAAAAAHEAAAAAAAEABP/wj6QAAAEAYgEAZa6/VU0JAAAANteqUw==';
binlog 'bBf2ZBMBAAAANAAAAHUkAAAAAHEAAAAAAAEABHRlc3QAAnQxAAQDDw8IBP0C4h0AaTGFIg==bBf2ZBgBAAAASAAAAL0kAAAAAHEAAAAAAAEABP//8I+kAAABAGIBAGWuv1VNCQAAAPBuWwAAAQBiAQBlrr9VTQkAAADxS9Lu';
drop table t1;
set global slave_exec_mode=default;
#
# End of 10.4 tests
#
include/rpl_end.inc

View File

@ -2,9 +2,9 @@
# Long unique bugs related to master slave replication
#
#
# MDEV-22722 Assertion "inited==NONE" failed in handler::ha_index_init on the slave during UPDATE
#
--echo #
--echo # MDEV-22722 Assertion "inited==NONE" failed in handler::ha_index_init on the slave during UPDATE
--echo #
--source include/have_binlog_format_row.inc
--source include/master-slave.inc
@ -16,9 +16,34 @@ update t1 set a1 = 'd' limit 1;
update t1 set a1 = 'd2' where i1= 2;
sync_slave_with_master;
connection slave;
connection master;
drop table t1;
--echo #
--echo # MDEV-32093 long uniques break old->new replication
--echo #
# this is techically a bug in replication, but it needs an old master
# so we'll run it as a non-replicated test with BINLOG command
sync_slave_with_master;
create table t1 (id int not null, b1 varchar(255) not null, b2 varchar(2550) not null, unique (id), unique key (b1,b2) using hash) default charset utf8mb3;
set global slave_exec_mode=idempotent;
# Format_description_log_event, MariaDB-10.5.15
binlog 'aRf2ZA8BAAAA/AAAAAABAAAAAAQAMTAuNS4xNS1NYXJpYURCLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABpF/ZkEzgNAAgAEgAEBAQEEgAA5AAEGggAAAAICAgCAAAACgoKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEEwQADQgICAoKCgFRmTlk';
### INSERT t1 VALUES (42127, 'b', 'e', 39952170926)
binlog 'bBf2ZBMBAAAANAAAAJgHAAAAAHEAAAAAAAEABHRlc3QAAnQxAAQDDw8IBP0C4h0AeqMD4A==bBf2ZBcBAAAANAAAAMwHAAAAAHEAAAAAAAEABP/wj6QAAAEAYgEAZa6/VU0JAAAANteqUw==';
binlog 'bBf2ZBMBAAAANAAAAJgHAAAAAHEAAAAAAAEABHRlc3QAAnQxAAQDDw8IBP0C4h0AeqMD4A==bBf2ZBcBAAAANAAAAMwHAAAAAHEAAAAAAAEABP/wj6QAAAEAYgEAZa6/VU0JAAAANteqUw==';
### UPDATE t1 WHERE (42127, 'b', 'e', 39952170926) SET (23406, 'b', 'e', 39952170926)
binlog 'bBf2ZBMBAAAANAAAAHUkAAAAAHEAAAAAAAEABHRlc3QAAnQxAAQDDw8IBP0C4h0AaTGFIg==bBf2ZBgBAAAASAAAAL0kAAAAAHEAAAAAAAEABP//8I+kAAABAGIBAGWuv1VNCQAAAPBuWwAAAQBiAQBlrr9VTQkAAADxS9Lu';
drop table t1;
set global slave_exec_mode=default;
--echo #
--echo # End of 10.4 tests
--echo #
--source include/rpl_end.inc

View File

@ -30,6 +30,8 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT * FROM t1 WHERE s2='a' COLLATE latin1_german1_ci;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL s2 NULL NULL NULL 10 Using where
Warnings:
Note 1105 Cannot use key `s2` part[0] for lookup: `test`.`t1`.`s2` of collation `latin1_swedish_ci` = "'a' collate latin1_german1_ci" of collation `latin1_german1_ci`
EXPLAIN SELECT * FROM t1 WHERE s1 BETWEEN 'a' AND 'b' COLLATE latin1_german1_ci;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range s1 s1 11 NULL 2 Using index condition; Rowid-ordered scan

View File

@ -1384,12 +1384,17 @@ INSERT INTO t1 (i) VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19),
EXPLAIN DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 26 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` >= "10" of type `int`
Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` <= "18" of type `int`
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` >= "10" of type `int`
Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` <= "18" of type `int`
Note 1003 delete from `test`.`t1` where `test`.`t1`.`i` > 10 and `test`.`t1`.`i` <= 18 order by `test`.`t1`.`i` limit 5
# Status of EXPLAIN EXTENDED query
Variable_name Value
@ -1400,6 +1405,8 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL i NULL NULL NULL 26 100.00 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` >= "10" of type `int`
Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t1`.`i` of type `char` <= "18" of type `int`
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`i` AS `i` from `test`.`t1` where `test`.`t1`.`i` > 10 and `test`.`t1`.`i` <= 18 order by `test`.`t1`.`i` limit 5
# Status of EXPLAIN EXTENDED "equivalent" SELECT query execution
Variable_name Value
@ -1530,12 +1537,15 @@ INSERT INTO t2 SELECT i, i, i, i FROM t1;
EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 26 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `a` part[1] for lookup: `test`.`t2`.`b` of type `char` = "10" of type `int`
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `a` part[1] for lookup: `test`.`t2`.`b` of type `char` = "10" of type `int`
Note 1003 delete from `test`.`t2` where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5
# Status of EXPLAIN EXTENDED query
Variable_name Value
@ -1546,6 +1556,7 @@ EXPLAIN EXTENDED SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `a` part[1] for lookup: `test`.`t2`.`b` of type `char` = "10" of type `int`
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5
# Status of EXPLAIN EXTENDED "equivalent" SELECT query execution
Variable_name Value
@ -1582,12 +1593,15 @@ INSERT INTO t2 SELECT i, i, i, i FROM t1;
EXPLAIN DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 26 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `a` part[1] for lookup: `test`.`t2`.`b` of type `char` = "10" of type `int`
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `a` part[1] for lookup: `test`.`t2`.`b` of type `char` = "10" of type `int`
Note 1003 delete from `test`.`t2` where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5
# Status of EXPLAIN EXTENDED query
Variable_name Value
@ -1598,6 +1612,7 @@ EXPLAIN EXTENDED SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `a` part[1] for lookup: `test`.`t2`.`b` of type `char` = "10" of type `int`
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5
# Status of EXPLAIN EXTENDED "equivalent" SELECT query execution
Variable_name Value
@ -1876,12 +1891,17 @@ INSERT INTO t2 (i) SELECT i FROM t1;
EXPLAIN UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 26 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` >= "10" of type `int`
Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` <= "18" of type `int`
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` >= "10" of type `int`
Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` <= "18" of type `int`
Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where `test`.`t2`.`i` > 10 and `test`.`t2`.`i` <= 18 order by `test`.`t2`.`i` limit 5
# Status of EXPLAIN EXTENDED query
Variable_name Value
@ -1892,6 +1912,8 @@ EXPLAIN EXTENDED SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL i NULL NULL NULL 26 100.00 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` >= "10" of type `int`
Note 1105 Cannot use key `i` part[0] for lookup: `test`.`t2`.`i` of type `char` <= "18" of type `int`
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`i` AS `i` from `test`.`t2` where `test`.`t2`.`i` > 10 and `test`.`t2`.`i` <= 18 order by `test`.`t2`.`i` limit 5
# Status of EXPLAIN EXTENDED "equivalent" SELECT query execution
Variable_name Value
@ -2025,12 +2047,15 @@ INSERT INTO t2 SELECT i, i, i, i FROM t1;
EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 26 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `a` part[1] for lookup: `test`.`t2`.`b` of type `char` = "10" of type `int`
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `a` part[1] for lookup: `test`.`t2`.`b` of type `char` = "10" of type `int`
Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5
# Status of EXPLAIN EXTENDED query
Variable_name Value
@ -2041,6 +2066,7 @@ EXPLAIN EXTENDED SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `a` part[1] for lookup: `test`.`t2`.`b` of type `char` = "10" of type `int`
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5
# Status of EXPLAIN EXTENDED "equivalent" SELECT query execution
Variable_name Value
@ -2077,12 +2103,15 @@ INSERT INTO t2 SELECT i, i, i, i FROM t1;
EXPLAIN UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 26 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `a` part[1] for lookup: `test`.`t2`.`b` of type `char` = "10" of type `int`
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `a` part[1] for lookup: `test`.`t2`.`b` of type `char` = "10" of type `int`
Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5
# Status of EXPLAIN EXTENDED query
Variable_name Value
@ -2093,6 +2122,7 @@ EXPLAIN EXTENDED SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort
Warnings:
Note 1105 Cannot use key `a` part[1] for lookup: `test`.`t2`.`b` of type `char` = "10" of type `int`
Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d` from `test`.`t2` where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5
# Status of EXPLAIN EXTENDED "equivalent" SELECT query execution
Variable_name Value

View File

@ -46,7 +46,7 @@ rmdir $ddir;
# MDEV-28471 - mysql_install_db.exe fails with --innodb-page-size=64K
--disable_result_log
exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --password=foo -R --innodb-page-size=64K --verbose
exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --password=foo -R --innodb-page-size=64K --verbose;
--enable_result_log
rmdir $ddir;

View File

@ -4,6 +4,7 @@
--source include/have_log_bin.inc
--source include/have_binlog_format_row.inc
--source include/have_normal_bzip.inc
#
#

View File

@ -4,7 +4,7 @@
--source include/have_log_bin.inc
--source include/have_binlog_format_statement.inc
--source include/have_normal_bzip.inc
#
#
# mysqlbinlog: compressed query event

View File

@ -215,6 +215,7 @@ The following specify which files/extra groups are read (specified before remain
Default flags for the regex library. Any combination of:
DOTALL, DUPNAMES, EXTENDED, EXTENDED_MORE, EXTRA,
MULTILINE, UNGREEDY
Use 'ALL' to set all combinations.
--default-storage-engine=name
The default storage engine for new tables
--default-time-zone=name
@ -490,12 +491,14 @@ The following specify which files/extra groups are read (specified before remain
--log-disabled-statements=name
Don't log certain types of statements to general log. Any
combination of: slave, sp
Use 'ALL' to set all combinations.
--log-error[=name] Log errors to file (instead of stdout). If file name is
not specified then 'datadir'/'log-basename'.err or the
'pid-file' path with extension .err is used
--log-isam[=name] Log all MyISAM changes to file.
--log-output=name How logs should be written. Any combination of: NONE,
FILE, TABLE
Use 'ALL' to set all combinations.
--log-queries-not-using-indexes
Log queries that are executed without benefit of any
index to the slow log if it is open. Same as
@ -514,15 +517,20 @@ The following specify which files/extra groups are read (specified before remain
--log-slow-disabled-statements=name
Don't log certain types of statements to slow log. Any
combination of: admin, call, slave, sp
Use 'ALL' to set all combinations.
--log-slow-filter=name
Log only certain types of queries to the slow log. If
variable empty alll kind of queries are logged. All
types are bound by slow_query_time, except
'not_using_index' which is always logged if enabled. Any
combination of: admin, filesort, filesort_on_disk,
variable empty all kind of queries are logged. All types
are bound by slow_query_time, except 'not_using_index'
which is always logged if enabled. Any combination of:
admin, filesort, filesort_on_disk,
filesort_priority_queue, full_join, full_scan,
not_using_index, query_cache, query_cache_miss, tmp_table,
tmp_table_on_disk
Use 'ALL' to set all combinations.
--log-slow-max-warnings=#
Max numbers of warnings printed to slow query log per
statement
--log-slow-min-examined-row-limit=#
Don't write queries to slow log that examine fewer rows
than that
@ -550,7 +558,8 @@ The following specify which files/extra groups are read (specified before remain
(Defaults to on; use --skip-log-slow-slave-statements to disable.)
--log-slow-verbosity=name
Verbosity level for the slow log. Any combination of:
innodb, query_plan, explain, engine, full
innodb, query_plan, explain, engine, warnings, full
Use 'ALL' to set all combinations.
--log-tc=name Path to transaction coordinator log (used for
transactions that affect more than one storage engine,
when binary log is disabled).
@ -668,6 +677,7 @@ The following specify which files/extra groups are read (specified before remain
Specifies how corrupted tables should be automatically
repaired. Any combination of: DEFAULT, BACKUP, FORCE,
QUICK, BACKUP_ALL, OFF
Use 'ALL' to set all combinations.
--myisam-repair-threads=#
If larger than 1, when repairing a MyISAM table all
indexes will be created in parallel, with one thread per
@ -696,6 +706,11 @@ The following specify which files/extra groups are read (specified before remain
--net-write-timeout=#
Number of seconds to wait for a block to be written to a
connection before aborting the write
--note-verbosity=name
Verbosity level for note-warnings given to the user. See
also @@sql_notes.. Any combination of: basic,
unusable_keys, explain
Use 'ALL' to set all combinations.
--old Use compatible behavior from previous MariaDB version.
See also --old-mode
--old-alter-table[=name]
@ -707,6 +722,7 @@ The following specify which files/extra groups are read (specified before remain
NO_DUP_KEY_WARNINGS_WITH_IGNORE, NO_PROGRESS_INFO,
ZERO_DATE_TIME_CAST, UTF8_IS_UTF8MB3,
IGNORE_INDEX_ONLY_FOR_JOIN, COMPAT_5_1_CHECKSUM
Use 'ALL' to set all combinations.
--old-passwords Use old password encryption method (needed for 4.0 and
older clients)
--old-style-user-limits
@ -749,6 +765,10 @@ The following specify which files/extra groups are read (specified before remain
--optimizer-max-sel-arg-weight=#
The maximum weight of the SEL_ARG graph. Set to 0 for no
limit
--optimizer-max-sel-args=#
The maximum number of SEL_ARG objects created when
optimizing a range. If more objects would be needed, the
range will not be used by the optimizer.
--optimizer-prune-level=#
Controls the heuristic(s) applied during query
optimization to prune less-promising partial plans from
@ -1358,6 +1378,7 @@ The following specify which files/extra groups are read (specified before remain
variable is empty, no conversions are allowed and it is
expected that the types match exactly. Any combination
of: ALL_LOSSY, ALL_NON_LOSSY
Use 'ALL' to set all combinations.
--slow-launch-time=#
If creating the thread takes longer than this value (in
seconds), the Slow_launch_threads counter will be
@ -1388,6 +1409,7 @@ The following specify which files/extra groups are read (specified before remain
NO_ENGINE_SUBSTITUTION, PAD_CHAR_TO_FULL_LENGTH,
EMPTY_STRING_IS_NULL, SIMULTANEOUS_ASSIGNMENT,
TIME_ROUND_FRACTIONAL
Use 'ALL' to set all combinations.
--sql-safe-updates If set to 1, UPDATEs and DELETEs need either a key in the
WHERE clause, or a LIMIT clause, or else they will
aborted. Prevents the common mistake of accidentally
@ -1498,6 +1520,7 @@ The following specify which files/extra groups are read (specified before remain
--time-format=name The TIME format (ignored)
--tls-version=name TLS protocol version for secure connections.. Any
combination of: TLSv1.0, TLSv1.1, TLSv1.2, TLSv1.3
Use 'ALL' to set all combinations.
--tmp-disk-table-size=#
Max size for data for an internal temporary on-disk
MyISAM or Aria table.
@ -1679,6 +1702,7 @@ log-slave-updates FALSE
log-slow-admin-statements TRUE
log-slow-disabled-statements sp
log-slow-filter admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
log-slow-max-warnings 10
log-slow-min-examined-row-limit 0
log-slow-query FALSE
log-slow-query-time 10
@ -1736,6 +1760,7 @@ net-buffer-length 16384
net-read-timeout 30
net-retry-count 10
net-write-timeout 60
note-verbosity basic,explain
old FALSE
old-alter-table DEFAULT
old-mode UTF8_IS_UTF8MB3
@ -1750,6 +1775,7 @@ optimizer-key-copy-cost 0.015685
optimizer-key-lookup-cost 0.435777
optimizer-key-next-find-cost 0.082347
optimizer-max-sel-arg-weight 32000
optimizer-max-sel-args 16000
optimizer-prune-level 2
optimizer-row-copy-cost 0.060866
optimizer-row-lookup-cost 0.130839

View File

@ -5399,15 +5399,15 @@ slow_log CREATE TABLE `slow_log` (
`user_host` mediumtext NOT NULL,
`query_time` time(6) NOT NULL,
`lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`rows_sent` bigint(20) unsigned NOT NULL,
`rows_examined` bigint(20) unsigned NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL,
`rows_affected` int(11) NOT NULL
`rows_affected` bigint(20) unsigned NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='Slow log'
SET @@global.log_output= @old_log_output_state;
SET @@global.slow_query_log= @old_slow_query_log_state;
@ -5886,15 +5886,15 @@ CREATE TABLE IF NOT EXISTS `slow_log` (
`user_host` mediumtext NOT NULL,
`query_time` time(6) NOT NULL,
`lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`rows_sent` bigint(20) unsigned NOT NULL,
`rows_examined` bigint(20) unsigned NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL,
`rows_affected` int(11) NOT NULL
`rows_affected` bigint(20) unsigned NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='Slow log';
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `innodb_index_stats`;
@ -5981,15 +5981,15 @@ CREATE TABLE IF NOT EXISTS `slow_log` (
`user_host` mediumtext NOT NULL,
`query_time` time(6) NOT NULL,
`lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`rows_sent` bigint(20) unsigned NOT NULL,
`rows_examined` bigint(20) unsigned NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL,
`rows_affected` int(11) NOT NULL
`rows_affected` bigint(20) unsigned NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='Slow log';
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `innodb_index_stats`;
@ -6086,15 +6086,15 @@ CREATE TABLE IF NOT EXISTS `slow_log` (
`user_host` mediumtext NOT NULL,
`query_time` time(6) NOT NULL,
`lock_time` time(6) NOT NULL,
`rows_sent` int(11) NOT NULL,
`rows_examined` int(11) NOT NULL,
`rows_sent` bigint(20) unsigned NOT NULL,
`rows_examined` bigint(20) unsigned NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL,
`rows_affected` int(11) NOT NULL
`rows_affected` bigint(20) unsigned NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='Slow log';
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `innodb_index_stats`;
@ -6546,15 +6546,15 @@ DROP TABLE IF EXISTS mysql.column_stats;
<field Field="user_host" Type="mediumtext" Null="NO" Key="" Extra="" Comment="" />
<field Field="query_time" Type="time(6)" Null="NO" Key="" Extra="" Comment="" />
<field Field="lock_time" Type="time(6)" Null="NO" Key="" Extra="" Comment="" />
<field Field="rows_sent" Type="int(11)" Null="NO" Key="" Extra="" Comment="" />
<field Field="rows_examined" Type="int(11)" Null="NO" Key="" Extra="" Comment="" />
<field Field="rows_sent" Type="bigint(20) unsigned" Null="NO" Key="" Extra="" Comment="" />
<field Field="rows_examined" Type="bigint(20) unsigned" Null="NO" Key="" Extra="" Comment="" />
<field Field="db" Type="varchar(512)" Null="NO" Key="" Extra="" Comment="" />
<field Field="last_insert_id" Type="int(11)" Null="NO" Key="" Extra="" Comment="" />
<field Field="insert_id" Type="int(11)" Null="NO" Key="" Extra="" Comment="" />
<field Field="server_id" Type="int(10) unsigned" Null="NO" Key="" Extra="" Comment="" />
<field Field="sql_text" Type="mediumtext" Null="NO" Key="" Extra="" Comment="" />
<field Field="thread_id" Type="bigint(21) unsigned" Null="NO" Key="" Extra="" Comment="" />
<field Field="rows_affected" Type="int(11)" Null="NO" Key="" Extra="" Comment="" />
<field Field="rows_affected" Type="bigint(20) unsigned" Null="NO" Key="" Extra="" Comment="" />
<options Name="slow_log" Engine="CSV" Version="10" Row_format="Dynamic" Rows="2" Avg_row_length="0" Data_length="0" Max_data_length="0" Index_length="0" Data_free="0" Collation="utf8mb3_general_ci" Create_options="" Comment="Slow log" Max_index_length="0" Temporary="N" />
</table_structure>

View File

@ -2,7 +2,6 @@
# an additional util connection and other statistics data
-- source include/no_view_protocol.inc
--source include/one_thread_per_connection.inc
#
# Test the --thread-handler=no-threads option
#

View File

@ -1,4 +1,5 @@
drop table if exists t1,t2;
set @@note_verbosity=replace(@@note_verbosity,"explain","");
create table t1 (a int, b int not null,unique key (a,b),index(b)) engine=myisam;
insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
Warnings:
@ -475,3 +476,5 @@ INSERT INTO t1 VALUES ('9','k'),(NULL,'r');
SELECT * FROM t1 WHERE (f3 = 83) OR (f10 = 'z' AND f3 IS NULL);
f3 f10
DROP TABLE t1;
## end of 10.6 tests
set @@note_verbosity=default;

View File

@ -5,6 +5,9 @@
drop table if exists t1,t2;
--enable_warnings
# Disable wrong key warnings for this test (to test @@note_verbosity usage)
set @@note_verbosity=replace(@@note_verbosity,"explain","");
create table t1 (a int, b int not null,unique key (a,b),index(b)) engine=myisam;
insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
explain select * from t1 where a is null;
@ -288,3 +291,6 @@ INSERT INTO t1 VALUES ('9','k'),(NULL,'r');
SELECT * FROM t1 WHERE (f3 = 83) OR (f10 = 'z' AND f3 IS NULL);
DROP TABLE t1;
--echo ## end of 10.6 tests
set @@note_verbosity=default;

View File

@ -112,9 +112,12 @@ set sort_buffer_size=262144*10;
--source include/analyze-format.inc
eval analyze format=json $query;
flush status;
# Enable view-protocol after fix MDEV-27871
--disable_view_protocol
--disable_ps2_protocol
eval $query;
--enable_ps2_protocol
--enable_view_protocol
show status like '%sort%';
set sort_buffer_size=default;
@ -126,9 +129,12 @@ set sort_buffer_size=32768;
--source include/analyze-format.inc
eval analyze format=json $query;
flush status;
# Enable view-protocol after fix MDEV-27871
--disable_view_protocol
--disable_ps2_protocol
eval $query;
--enable_ps2_protocol
--enable_view_protocol
show status like '%sort%';
set sort_buffer_size=default;

View File

@ -2859,6 +2859,19 @@ id select_type table type possible_keys key key_len ref rows Extra
set optimizer_switch=@tmp_os;
drop table t1,t2,t3;
#
# MDEV-32388 MSAN / Valgrind errors in
# Item_func_like::get_mm_leaf upon query from partitioned table
#
CREATE TABLE t1 (a INT) PARTITION BY HASH(a) PARTITIONS 2;
INSERT INTO t1 VALUES (1),(2);
SELECT * FROM t1 WHERE a LIKE '1';
a
1
DROP TABLE t1;
#
# End of 10.6 tests
#
#
# MDEV-31494 Server crashes in ha_partition::index_blocks /
# get_key_scans_params
#

View File

@ -3067,6 +3067,20 @@ set optimizer_switch=@tmp_os;
drop table t1,t2,t3;
--echo #
--echo # MDEV-32388 MSAN / Valgrind errors in
--echo # Item_func_like::get_mm_leaf upon query from partitioned table
--echo #
CREATE TABLE t1 (a INT) PARTITION BY HASH(a) PARTITIONS 2;
INSERT INTO t1 VALUES (1),(2);
SELECT * FROM t1 WHERE a LIKE '1';
DROP TABLE t1;
--echo #
--echo # End of 10.6 tests
--echo #
--echo #
--echo # MDEV-31494 Server crashes in ha_partition::index_blocks /
--echo # get_key_scans_params

View File

@ -350,7 +350,6 @@ WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0;
VARIABLE_NAME VARIABLE_VALUE
HANDLER_COMMIT 1
HANDLER_READ_FIRST 1
HANDLER_READ_KEY 8
HANDLER_TMP_WRITE 24
# Should be 1 commit
# 4 locks (1 ha_partition + 1 ha_innobase) x 2 (lock/unlock)
@ -775,7 +774,7 @@ SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS
WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0;
VARIABLE_NAME VARIABLE_VALUE
HANDLER_COMMIT 1
HANDLER_READ_KEY 8
HANDLER_READ_KEY 6
HANDLER_READ_RND_NEXT 2
HANDLER_TMP_WRITE 24
HANDLER_UPDATE 2

View File

@ -642,6 +642,8 @@ id select_type table type possible_keys key key_len ref rows Extra
explain select * from t1 where a='aaa' collate latin1_german1_ci;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL a NULL NULL NULL 9 Using where
Warnings:
Note 1105 Cannot use key `a` part[0] for lookup: `test`.`t1`.`a` of collation `latin1_swedish_ci` = "'aaa' collate latin1_german1_ci" of collation `latin1_german1_ci`
drop table t1;
CREATE TABLE t1 (
`CLIENT` char(3) character set latin1 collate latin1_bin NOT NULL default '000',
@ -2236,6 +2238,8 @@ INSERT INTO t2 VALUES ('2001-01-01 11:22:33');
EXPLAIN SELECT * FROM t2 WHERE b=CAST('2001-01-01' AS DATE);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index b b 67 NULL 5 Using where; Using index
Warnings:
Note 1105 Cannot use key `b` part[0] for lookup: `test`.`t2`.`b` of type `varchar` = "cast('2001-01-01' as date)" of type `date`
SELECT * FROM t2 WHERE b=CAST('2001-01-01' AS DATE);
b
2001#01#01
@ -2250,6 +2254,8 @@ EXPLAIN SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
1 SIMPLE t2 ALL b NULL NULL NULL 5 Range checked for each record (index map: 0x1)
Warnings:
Note 1105 Cannot use key `b` part[0] for lookup: `test`.`t2`.`b` of type `varchar` = "`t1`.`a`" of type `datetime`
SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b;
a b
2001-01-01 00:00:00 2001#01#01
@ -2262,6 +2268,8 @@ EXPLAIN SELECT * FROM t1, t2 WHERE b=a ORDER BY BINARY a, BINARY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
1 SIMPLE t2 ALL b NULL NULL NULL 5 Range checked for each record (index map: 0x1)
Warnings:
Note 1105 Cannot use key `b` part[0] for lookup: `test`.`t2`.`b` of type `varchar` = "`t1`.`a`" of type `datetime`
SELECT * FROM t1, t2 WHERE b=a ORDER BY BINARY a, BINARY b;
a b
2001-01-01 00:00:00 2001#01#01

View File

@ -645,6 +645,8 @@ id select_type table type possible_keys key key_len ref rows Extra
explain select * from t1 where a='aaa' collate latin1_german1_ci;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL a NULL NULL NULL 9 Using where
Warnings:
Note 1105 Cannot use key `a` part[0] for lookup: `test`.`t1`.`a` of collation `latin1_swedish_ci` = "'aaa' collate latin1_german1_ci" of collation `latin1_german1_ci`
drop table t1;
CREATE TABLE t1 (
`CLIENT` char(3) character set latin1 collate latin1_bin NOT NULL default '000',
@ -2239,6 +2241,8 @@ INSERT INTO t2 VALUES ('2001-01-01 11:22:33');
EXPLAIN SELECT * FROM t2 WHERE b=CAST('2001-01-01' AS DATE);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index b b 67 NULL 5 Using where; Using index
Warnings:
Note 1105 Cannot use key `b` part[0] for lookup: `test`.`t2`.`b` of type `varchar` = "cast('2001-01-01' as date)" of type `date`
SELECT * FROM t2 WHERE b=CAST('2001-01-01' AS DATE);
b
2001#01#01
@ -2253,6 +2257,8 @@ EXPLAIN SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
1 SIMPLE t2 ALL b NULL NULL NULL 5 Range checked for each record (index map: 0x1)
Warnings:
Note 1105 Cannot use key `b` part[0] for lookup: `test`.`t2`.`b` of type `varchar` = "`t1`.`a`" of type `datetime`
SELECT * FROM t1, t2 WHERE a=b ORDER BY BINARY a, BINARY b;
a b
2001-01-01 00:00:00 2001#01#01
@ -2265,6 +2271,8 @@ EXPLAIN SELECT * FROM t1, t2 WHERE b=a ORDER BY BINARY a, BINARY b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
1 SIMPLE t2 ALL b NULL NULL NULL 5 Range checked for each record (index map: 0x1)
Warnings:
Note 1105 Cannot use key `b` part[0] for lookup: `test`.`t2`.`b` of type `varchar` = "`t1`.`a`" of type `datetime`
SELECT * FROM t1, t2 WHERE b=a ORDER BY BINARY a, BINARY b;
a b
2001-01-01 00:00:00 2001#01#01

View File

@ -1369,4 +1369,16 @@ SET sql_mode=ORACLE;
SET STATEMENT max_statement_time=30 FOR DELETE FROM mysql.user where user = 'unknown';
SET sql_mode=default;
SET STATEMENT max_statement_time=30 FOR DELETE FROM mysql.user where user = 'unknown';
#
# MDEV-17711 Assertion `arena_for_set_stmt== 0' failed in LEX::set_arena_for_set_stmt upon SET STATEMENT
#
set rand_seed1=1, rand_seed2=2;
set statement rand_seed1=4 for select 2, @@rand_seed1, @@rand_seed2;
set statement rand_seed2=5 for select 3, @@rand_seed1, @@rand_seed2 $
2 @@rand_seed1 @@rand_seed2
2 4 2
3 @@rand_seed1 @@rand_seed2
3 1 5
#
# End of 10.4 tests
#

View File

@ -1199,4 +1199,18 @@ SET STATEMENT max_statement_time=30 FOR DELETE FROM mysql.user where user = 'unk
SET sql_mode=default;
SET STATEMENT max_statement_time=30 FOR DELETE FROM mysql.user where user = 'unknown';
--echo #
--echo # MDEV-17711 Assertion `arena_for_set_stmt== 0' failed in LEX::set_arena_for_set_stmt upon SET STATEMENT
--echo #
--disable_ps_protocol
--delimiter $
set rand_seed1=1, rand_seed2=2;
set statement rand_seed1=4 for select 2, @@rand_seed1, @@rand_seed2;
set statement rand_seed2=5 for select 3, @@rand_seed1, @@rand_seed2 $
--delimiter ;
--enable_ps_protocol
--echo #
--echo # End of 10.4 tests
--echo #

View File

@ -8923,6 +8923,31 @@ CREATE TABLE t1 (a INT);
CREATE PROCEDURE p1() SELECT 1 FROM t1 PROCEDURE ANALYSE( 10, (SELECT a FROM t1));
ERROR 42000: PROCEDURE does not support subqueries or stored functions
DROP TABLE t1;
#
# MDEV-23902: MariaDB crash on calling function
#
CREATE FUNCTION f2 () RETURNS VARCHAR(1)
BEGIN
DECLARE rec1 ROW TYPE OF v1;
SELECT z INTO rec1 FROM v1;
RETURN 1;
END|
CREATE FUNCTION f1 () RETURNS VARCHAR(1) RETURN f2() ;
CREATE FUNCTION f3 () RETURNS VARCHAR(1) RETURN f_not_exist();
CREATE VIEW v1 AS SELECT f3() z;
SELECT f1();
ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
# Check that crash doen't happen in case f3 completes with success.
DROP FUNCTION f3;
CREATE FUNCTION f3 () RETURNS VARCHAR(1) RETURN '!';
SELECT f1();
f1()
1
# Clean up
DROP FUNCTION f1;
DROP FUNCTION f2;
DROP FUNCTION f3;
DROP VIEW v1;
# End of 10.4 tests
#
#

View File

@ -10534,6 +10534,38 @@ CREATE PROCEDURE p1() SELECT 1 FROM t1 PROCEDURE ANALYSE( 10, (SELECT a FROM t1)
DROP TABLE t1;
--echo #
--echo # MDEV-23902: MariaDB crash on calling function
--echo #
--delimiter |
CREATE FUNCTION f2 () RETURNS VARCHAR(1)
BEGIN
DECLARE rec1 ROW TYPE OF v1;
SELECT z INTO rec1 FROM v1;
RETURN 1;
END|
--delimiter ;
CREATE FUNCTION f1 () RETURNS VARCHAR(1) RETURN f2() ;
CREATE FUNCTION f3 () RETURNS VARCHAR(1) RETURN f_not_exist();
CREATE VIEW v1 AS SELECT f3() z;
--error ER_VIEW_INVALID
SELECT f1();
--echo # Check that crash doen't happen in case f3 completes with success.
DROP FUNCTION f3;
CREATE FUNCTION f3 () RETURNS VARCHAR(1) RETURN '!';
SELECT f1();
--echo # Clean up
DROP FUNCTION f1;
DROP FUNCTION f2;
DROP FUNCTION f3;
DROP VIEW v1;
--echo # End of 10.4 tests
--echo #

View File

@ -66,3 +66,5 @@ VARIABLE_VALUE like '%AES128-SHA%'
1
disconnect ssl_con;
connection default;
call mtr.add_suppression("TLSv1.0 and TLSv1.1 are insecure");
FOUND 2 /TLSv1.0 and TLSv1.1 are insecure/ in mysqld.1.err

View File

@ -2,6 +2,11 @@
# Various tests that require setting of a specific ssl_cipher
# which currently doesn't work in OpenSSL 1.1.1
#
--disable_query_log
CALL mtr.add_suppression("are insecure");
--enable_query_log
--source include/have_ssl_communication.inc
if (`select @@version_ssl_library like 'OpenSSL 1.1.1%'`) {
@ -101,3 +106,9 @@ SHOW STATUS LIKE 'Ssl_cipher';
SELECT VARIABLE_VALUE like '%AES128-SHA%' FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher_list';
disconnect ssl_con;
connection default;
# MDEV-31369 Disable TLS v1.0 and 1.1 for MariaDB
call mtr.add_suppression("TLSv1.0 and TLSv1.1 are insecure");
--let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err
--let SEARCH_PATTERN= TLSv1.0 and TLSv1.1 are insecure
--source include/search_pattern_in_file.inc

View File

@ -562,14 +562,14 @@ test.t1 analyze Warning Engine-independent statistics are not collected for colu
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 pk 1 2 0.0000 4.0000 1.0000 NULL NULL NULL
DELETE FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='t';
INSERT INTO mysql.column_stats VALUES
('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 pk 1 2 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 t bar foo 0.0000 3.0000 1.0000 0 NULL NULL
SELECT pk FROM t1;
pk
@ -593,7 +593,7 @@ pk c
2 bar
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 pk 1 2 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 c bar foo 0.0000 3.0000 1.0000 0 NULL NULL
CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
SELECT * FROM t1;
@ -923,4 +923,82 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 2.78 10.00 Using where
drop table t1;
set @@global.histogram_size=@save_histogram_size;
#
# End of 10.4 tests
#
#
# MDEV-29693 ANALYZE TABLE still flushes table definition cache
# when engine-independent statistics is used
#
create table t1 (a int);
insert into t1 select seq from seq_0_to_99;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status Table is already up to date
explain extended select count(*) from t1 where a < 50;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 50.51 Using where
Warnings:
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`a` < 50
connect con1, localhost, root,,;
connection con1;
explain extended select count(*) from t1 where a < 50;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 50.51 Using where
Warnings:
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`a` < 50
connection default;
update t1 set a= a +100;
# Explain shows outdated statistics:
explain extended select count(*) from t1 where a < 50;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 50.51 Using where
Warnings:
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`a` < 50
connection con1;
explain extended select count(*) from t1 where a < 50;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 50.51 Using where
Warnings:
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`a` < 50
connection default;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
# Now explain shows updated statistics:
explain extended select count(*) from t1 where a < 50;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 1.00 Using where
Warnings:
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`a` < 50
connection con1;
explain extended select count(*) from t1 where a < 50;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 1.00 Using where
Warnings:
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`a` < 50
connection con1;
# Run update and analyze in con1:
update t1 set a= a - 150;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
connection default;
# Explain shows updated statistics:
explain extended select count(*) from t1 where a < 50;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 100.00 Using where
Warnings:
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`a` < 50
disconnect con1;
drop table t1;
#
# End of 10.6 tests
#

View File

@ -1,7 +1,6 @@
# Tests will be skipped for the view protocol because the view protocol creates
# an additional util connection and other statistics data
-- source include/no_view_protocol.inc
--source include/no_view_protocol.inc
--source include/have_stat_tables.inc
--source include/have_partition.inc
--source include/have_sequence.inc
@ -641,4 +640,64 @@ drop table t1;
set @@global.histogram_size=@save_histogram_size;
--echo #
--echo # End of 10.4 tests
--echo #
--echo #
--echo # MDEV-29693 ANALYZE TABLE still flushes table definition cache
--echo # when engine-independent statistics is used
--echo #
create table t1 (a int);
insert into t1 select seq from seq_0_to_99;
analyze table t1 persistent for all;
analyze table t1 persistent for all;
explain extended select count(*) from t1 where a < 50;
connect (con1, localhost, root,,);
--connection con1
explain extended select count(*) from t1 where a < 50;
let $open_tables=`select variable_value from information_schema.global_status where variable_name="OPENED_TABLES"`;
--connection default
update t1 set a= a +100;
--echo # Explain shows outdated statistics:
explain extended select count(*) from t1 where a < 50;
--connection con1
explain extended select count(*) from t1 where a < 50;
--connection default
analyze table t1 persistent for all;
--echo # Now explain shows updated statistics:
explain extended select count(*) from t1 where a < 50;
--connection con1
explain extended select count(*) from t1 where a < 50;
--connection con1
--echo # Run update and analyze in con1:
update t1 set a= a - 150;
analyze table t1 persistent for all;
--connection default
--echo # Explain shows updated statistics:
explain extended select count(*) from t1 where a < 50;
disconnect con1;
let $new_open_tables=`select variable_value from information_schema.global_status where variable_name="OPENED_TABLES"`;
if ($open_tables != $new_open_tables)
{
--let $diff=`select $new_open_tables - $open_tables`
--echo "Fail: Test opened $diff new tables, 0 was expected"
}
drop table t1;
--echo #
--echo # End of 10.6 tests
--echo #

View File

@ -0,0 +1,190 @@
#
# Check that ANALYZE TABLE is remembered by MyISAM and Aria
#
create table t1 (a int) engine=myisam;
insert into t1 select seq from seq_0_to_99;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
flush tables;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status Table is already up to date
update t1 set a=100 where a=1;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
update t1 set a=100 where a=2;
flush tables;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
# Aria transactional=0
ALTER TABLE t1 ENGINE=aria transactional=0;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
update t1 set a=100 where a=10;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status Table is already up to date
flush tables;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status Table is already up to date
update t1 set a=100 where a=11;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
update t1 set a=100 where a=12;
flush tables;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status Table is already up to date
# Aria transactional=1
ALTER TABLE t1 ENGINE=aria transactional=1;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
update t1 set a=100 where a=20;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status Table is already up to date
flush tables;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status Table is already up to date
update t1 set a=100 where a=21;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
update t1 set a=100 where a=22;
flush tables;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
drop table t1;
#
# Test that histograms are read after flush
#
create table t1 (a int);
insert into t1 select seq from seq_1_to_10;
insert into t1 select A.seq from seq_10_to_20 A, seq_1_to_9 B;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
explain format=json select * from t1 where a between 2 and 5;
EXPLAIN
{
"query_block": {
"select_id": 1,
"cost": 0.027083745,
"nested_loop": [
{
"table": {
"table_name": "t1",
"access_type": "ALL",
"loops": 1,
"rows": 109,
"cost": 0.027083745,
"filtered": 3.669724703,
"attached_condition": "t1.a between 2 and 5"
}
}
]
}
}
explain format=json select * from t1 where a between 12 and 15;
EXPLAIN
{
"query_block": {
"select_id": 1,
"cost": 0.027083745,
"nested_loop": [
{
"table": {
"table_name": "t1",
"access_type": "ALL",
"loops": 1,
"rows": 109,
"cost": 0.027083745,
"filtered": 33.02752304,
"attached_condition": "t1.a between 12 and 15"
}
}
]
}
}
flush tables;
set @@optimizer_use_condition_selectivity=3;
explain format=json select * from t1 where a between 2 and 5;
EXPLAIN
{
"query_block": {
"select_id": 1,
"cost": 0.027083745,
"nested_loop": [
{
"table": {
"table_name": "t1",
"access_type": "ALL",
"loops": 1,
"rows": 109,
"cost": 0.027083745,
"filtered": 15.78947353,
"attached_condition": "t1.a between 2 and 5"
}
}
]
}
}
set @@optimizer_use_condition_selectivity=4;
explain format=json select * from t1 where a between 2 and 5;
EXPLAIN
{
"query_block": {
"select_id": 1,
"cost": 0.027083745,
"nested_loop": [
{
"table": {
"table_name": "t1",
"access_type": "ALL",
"loops": 1,
"rows": 109,
"cost": 0.027083745,
"filtered": 3.669724703,
"attached_condition": "t1.a between 2 and 5"
}
}
]
}
}
drop table t1;
set @@optimizer_use_condition_selectivity=default;
#
# End of 10.6 tests
#

View File

@ -0,0 +1,72 @@
--source include/have_sequence.inc
--echo #
--echo # Check that ANALYZE TABLE is remembered by MyISAM and Aria
--echo #
create table t1 (a int) engine=myisam;
insert into t1 select seq from seq_0_to_99;
analyze table t1 persistent for all;
flush tables;
analyze table t1 persistent for all;
update t1 set a=100 where a=1;
analyze table t1 persistent for all;
update t1 set a=100 where a=2;
flush tables;
analyze table t1 persistent for all;
--echo # Aria transactional=0
ALTER TABLE t1 ENGINE=aria transactional=0;
analyze table t1 persistent for all;
update t1 set a=100 where a=10;
analyze table t1 persistent for all;
analyze table t1 persistent for all;
flush tables;
analyze table t1 persistent for all;
update t1 set a=100 where a=11;
analyze table t1 persistent for all;
update t1 set a=100 where a=12;
flush tables;
analyze table t1 persistent for all;
--echo # Aria transactional=1
ALTER TABLE t1 ENGINE=aria transactional=1;
analyze table t1 persistent for all;
update t1 set a=100 where a=20;
analyze table t1 persistent for all;
analyze table t1 persistent for all;
flush tables;
analyze table t1 persistent for all;
update t1 set a=100 where a=21;
analyze table t1 persistent for all;
update t1 set a=100 where a=22;
flush tables;
analyze table t1 persistent for all;
drop table t1;
--echo #
--echo # Test that histograms are read after flush
--echo #
create table t1 (a int);
insert into t1 select seq from seq_1_to_10;
insert into t1 select A.seq from seq_10_to_20 A, seq_1_to_9 B;
analyze table t1 persistent for all;
explain format=json select * from t1 where a between 2 and 5;
explain format=json select * from t1 where a between 12 and 15;
flush tables;
set @@optimizer_use_condition_selectivity=3;
explain format=json select * from t1 where a between 2 and 5;
set @@optimizer_use_condition_selectivity=4;
explain format=json select * from t1 where a between 2 and 5;
drop table t1;
set @@optimizer_use_condition_selectivity=default;
--echo #
--echo # End of 10.6 tests
--echo #

View File

@ -594,14 +594,14 @@ test.t1 analyze Warning Engine-independent statistics are not collected for colu
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 pk 1 2 0.0000 4.0000 1.0000 NULL NULL NULL
DELETE FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='t';
INSERT INTO mysql.column_stats VALUES
('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 pk 1 2 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 t bar foo 0.0000 3.0000 1.0000 0 NULL NULL
SELECT pk FROM t1;
pk
@ -625,7 +625,7 @@ pk c
2 bar
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 pk 1 2 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 c bar foo 0.0000 3.0000 1.0000 0 NULL NULL
CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
SELECT * FROM t1;
@ -955,7 +955,85 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 2.78 10.00 Using where
drop table t1;
set @@global.histogram_size=@save_histogram_size;
#
# End of 10.4 tests
#
#
# MDEV-29693 ANALYZE TABLE still flushes table definition cache
# when engine-independent statistics is used
#
create table t1 (a int);
insert into t1 select seq from seq_0_to_99;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
explain extended select count(*) from t1 where a < 50;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 50.51 Using where
Warnings:
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`a` < 50
connect con1, localhost, root,,;
connection con1;
explain extended select count(*) from t1 where a < 50;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 50.51 Using where
Warnings:
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`a` < 50
connection default;
update t1 set a= a +100;
# Explain shows outdated statistics:
explain extended select count(*) from t1 where a < 50;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 50.51 Using where
Warnings:
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`a` < 50
connection con1;
explain extended select count(*) from t1 where a < 50;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 50.51 Using where
Warnings:
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`a` < 50
connection default;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
# Now explain shows updated statistics:
explain extended select count(*) from t1 where a < 50;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 1.00 Using where
Warnings:
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`a` < 50
connection con1;
explain extended select count(*) from t1 where a < 50;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 1.00 Using where
Warnings:
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`a` < 50
connection con1;
# Run update and analyze in con1:
update t1 set a= a - 150;
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
connection default;
# Explain shows updated statistics:
explain extended select count(*) from t1 where a < 50;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 100 100.00 Using where
Warnings:
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`a` < 50
disconnect con1;
drop table t1;
#
# End of 10.6 tests
#
set global innodb_stats_persistent= @innodb_stats_persistent_save;
set global innodb_stats_persistent_sample_pages=
@innodb_stats_persistent_sample_pages_save;

View File

@ -2,6 +2,9 @@ create table t1 (a int);
alter table mysql.column_stats rename to mysql.column_stats1;
flush tables;
alter table t1 change a b varchar(100);
Warnings:
Warning 1177 Got error 1146 when trying to open statistics table `table_stats` for updating statistics
Warning 1177 Got error 1146 when trying to open statistics table `table_stats` for updating statistics
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (

View File

@ -72,7 +72,7 @@ db_name table_name cardinality
test t1 40
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
@ -95,7 +95,7 @@ COUNT(*)
SELECT * FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='a';
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
SELECT MIN(t1.a), MAX(t1.a),
(SELECT COUNT(*) FROM t1 WHERE t1.b IS NULL) /
(SELECT COUNT(*) FROM t1) AS "NULLS_RATIO(t1.a)",
@ -226,7 +226,7 @@ hist_size, hist_type, decode_histogram(hist_type,histogram)
FROM mysql.column_stats
ORDER BY db_name, table_name, column_name;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type decode_histogram(hist_type,histogram)
test t1 a 0 49 0.0000 1.0000 4 SINGLE_PREC_HB 0.180,0.204,0.247,0.184,0.184
test t1 a 0 49 0.0000 1.0000 NULL NULL NULL
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 4 SINGLE_PREC_HB 0.000,0.247,0.502,0.251,0.000
test t1 c aaaa dddddddd 0.1250 7.0000 4 SINGLE_PREC_HB 0.000,0.333,0.333,0.333,0.000
test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 4 SINGLE_PREC_HB 0.000,0.098,0.000,0.902,0.000
@ -246,7 +246,7 @@ hist_size, hist_type, decode_histogram(hist_type,histogram)
FROM mysql.column_stats
ORDER BY db_name, table_name, column_name;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type decode_histogram(hist_type,histogram)
test t1 a 0 49 0.0000 1.0000 8 DOUBLE_PREC_HB 0.18367,0.20407,0.24489,0.18367,0.18369
test t1 a 0 49 0.0000 1.0000 NULL NULL NULL
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 8 DOUBLE_PREC_HB 0.00000,0.24999,0.50001,0.25000,0.00000
test t1 c aaaa dddddddd 0.1250 7.0000 8 DOUBLE_PREC_HB 0.00000,0.33333,0.33333,0.33333,0.00000
test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 8 DOUBLE_PREC_HB 0.00000,0.10161,0.00000,0.89839,0.00000
@ -293,13 +293,13 @@ test t1 40
test t3 17
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL
test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL
test t3 a 0 38 0.0000 4.0000 1.0000 0 NULL NULL
test t3 a 0 38 0.0000 4.0000 1.0000 NULL NULL NULL
test t3 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.1765 18.0714 2.8000 0 NULL NULL
test t3 c aaaa dddddddd 0.1176 6.4000 3.7500 0 NULL NULL
SELECT * FROM mysql.index_stats;
@ -322,13 +322,13 @@ test s1 40
test t3 17
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test s1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test s1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test s1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
test s1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test s1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
test s1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL
test s1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL
test t3 a 0 38 0.0000 4.0000 1.0000 0 NULL NULL
test t3 a 0 38 0.0000 4.0000 1.0000 NULL NULL NULL
test t3 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.1765 18.0714 2.8000 0 NULL NULL
test t3 c aaaa dddddddd 0.1176 6.4000 3.7500 0 NULL NULL
SELECT * FROM mysql.index_stats;
@ -351,13 +351,13 @@ test t1 40
test t3 17
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL
test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL
test t3 a 0 38 0.0000 4.0000 1.0000 0 NULL NULL
test t3 a 0 38 0.0000 4.0000 1.0000 NULL NULL NULL
test t3 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.1765 18.0714 2.8000 0 NULL NULL
test t3 c aaaa dddddddd 0.1176 6.4000 3.7500 0 NULL NULL
SELECT * FROM mysql.index_stats;
@ -379,7 +379,7 @@ db_name table_name cardinality
test t1 40
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
@ -420,7 +420,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
test t1 f 1 5 0.2000 1.0000 6.4000 0 NULL NULL
@ -445,7 +445,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
@ -472,7 +472,7 @@ db_name table_name cardinality
test s1 40
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test s1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test s1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test s1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test s1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
test s1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL
@ -510,7 +510,7 @@ db_name table_name cardinality
test t1 40
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
@ -545,7 +545,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL
@ -556,6 +556,13 @@ test t1 PRIMARY 1 1.0000
test t1 idx2 1 7.0000
test t1 idx2 2 2.3846
test t1 idx3 1 8.5000
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(x) INDEXES();
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT * FROM mysql.column_stats where column_name="x";
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 x vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
ALTER TABLE t1 CHANGE COLUMN x b varchar(32);
SHOW CREATE TABLE t1;
Table Create Table
@ -574,7 +581,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL
@ -591,7 +598,7 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
@ -632,7 +639,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL
@ -661,7 +668,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL
@ -672,15 +679,15 @@ test t1 PRIMARY 1 1.0000
test t1 idx2 1 7.0000
test t1 idx2 2 2.3846
test t1 idx3 1 8.5000
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/save_column_stats'
INTO TABLE mysql.column_stats
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/save_column_stats' IGNORE
INTO TABLE mysql.column_stats
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/save_index_stats'
INTO TABLE mysql.index_stats
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
@ -714,7 +721,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL
@ -777,7 +784,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL
@ -792,7 +799,7 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 b NULL NULL 1.0000 NULL NULL 0 NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
@ -816,7 +823,7 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
@ -848,7 +855,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL
@ -878,7 +885,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL
@ -893,7 +900,7 @@ test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
@ -975,7 +982,7 @@ db_name table_name cardinality
test t1 40
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
@ -1006,8 +1013,8 @@ test t1 40
test t2 40
SELECT * FROM mysql.column_stats ORDER BY column_name, table_name;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t2 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t2 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
test t2 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
@ -1051,7 +1058,7 @@ db_name table_name cardinality
test t2 40
SELECT * FROM mysql.column_stats ORDER BY column_name;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t2 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t2 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t2 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
test t2 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t2 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
@ -1110,12 +1117,17 @@ test t2 idx4 1 6.2000
test t2 idx4 2 1.7222
test t2 idx4 3 1.1154
test t2 idx4 4 1.0000
SELECT * FROM mysql.column_stats where column_name="b";
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t2 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000 0 NULL NULL
ALTER TABLE t2 CHANGE COLUMN b b varchar(30);
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
db_name table_name index_name prefix_arity avg_frequency
test t2 idx2 1 7.0000
test t2 idx2 2 2.3846
test t2 idx3 1 8.5000
SELECT * FROM mysql.column_stats where column_name="b";
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
ANALYZE TABLE t2 PERSISTENT FOR COLUMNS ALL INDEXES ALL;
Table Op Msg_type Msg_text
test.t2 analyze status Engine-independent statistics collected
@ -1151,6 +1163,9 @@ test t2 idx4 1 6.2000
test t2 idx4 2 1.7222
test t2 idx4 3 1.1154
test t2 idx4 4 1.0000
SELECT * FROM mysql.column_stats where column_name="b";
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t2 b 0 zzzzzzzzzzzzzzzzzz 0.0000 13.9000 6.6667 0 NULL NULL
ANALYZE TABLE t2 PERSISTENT FOR COLUMNS ALL INDEXES ALL;
Table Op Msg_type Msg_text
test.t2 analyze status Engine-independent statistics collected
@ -1224,7 +1239,7 @@ test.t1 analyze Warning Engine-independent statistics are not collected for colu
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL
@ -1280,7 +1295,7 @@ db_name table_name cardinality
test t1 40
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 a 0 49 0.0000 4.0000 1.0000 0 NULL NULL
test t1 a 0 49 0.0000 4.0000 1.0000 NULL NULL NULL
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000 0 NULL NULL
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000 0 NULL NULL
test t1 e 0.01 0.112 0.2250 8.0000 6.2000 0 NULL NULL

View File

@ -315,6 +315,10 @@ SELECT * FROM mysql.column_stats;
--sorted_result
SELECT * FROM mysql.index_stats;
# Add 'x' back that was deleted above
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(x) INDEXES();
SELECT * FROM mysql.column_stats where column_name="x";
ALTER TABLE t1 CHANGE COLUMN x b varchar(32);
SHOW CREATE TABLE t1;
--sorted_result
@ -357,7 +361,7 @@ SELECT * FROM mysql.index_stats;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
eval
LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/save_column_stats'
LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/save_column_stats' IGNORE
INTO TABLE mysql.column_stats
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
@ -505,14 +509,17 @@ SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
ANALYZE TABLE t2 PERSISTENT FOR COLUMNS() INDEXES ALL;
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
SELECT * FROM mysql.column_stats where column_name="b";
ALTER TABLE t2 CHANGE COLUMN b b varchar(30);
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
SELECT * FROM mysql.column_stats where column_name="b";
ANALYZE TABLE t2 PERSISTENT FOR COLUMNS ALL INDEXES ALL;
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
ALTER TABLE t2 CHANGE COLUMN b b varchar(32);
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;
SELECT * FROM mysql.column_stats where column_name="b";
ANALYZE TABLE t2 PERSISTENT FOR COLUMNS ALL INDEXES ALL;
SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name;

Some files were not shown because too many files have changed in this diff Show More