mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge 10.4 into 10.5
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
# Copyright (c) 2006, 2017, Oracle and/or its affiliates.
|
||||
# Copyright (c) 2008, 2018, MariaDB Corporation
|
||||
# Copyright (c) 2008, 2019, MariaDB Corporation.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -150,9 +150,6 @@ INCLUDE(mysql_version)
|
||||
INCLUDE(cpack_source_ignore_files)
|
||||
INCLUDE(install_layout)
|
||||
INCLUDE(submodules)
|
||||
INCLUDE(wsrep)
|
||||
INCLUDE(cpack_rpm)
|
||||
INCLUDE(cpack_deb)
|
||||
|
||||
# Add macros
|
||||
INCLUDE(character_sets)
|
||||
@ -225,9 +222,6 @@ ENDIF()
|
||||
|
||||
OPTION(WITH_TSAN "Enable thread sanitizer" OFF)
|
||||
IF (WITH_TSAN)
|
||||
IF(SECURITY_HARDENED)
|
||||
MESSAGE(FATAL_ERROR "WITH_TSAN and SECURITY_HARDENED are mutually exclusive")
|
||||
ENDIF()
|
||||
MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=thread" DEBUG RELWITHDEBINFO)
|
||||
ENDIF()
|
||||
|
||||
@ -236,26 +230,25 @@ IF (WITH_UBSAN)
|
||||
MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=undefined -fno-sanitize=alignment -U_FORTIFY_SOURCE" DEBUG RELWITHDEBINFO)
|
||||
ENDIF()
|
||||
|
||||
IF(NOT WITH_TSAN)
|
||||
OPTION(WITH_MSAN "Enable memory sanitizer" OFF)
|
||||
IF (WITH_MSAN)
|
||||
MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=memory -fsanitize-memory-track-origins -U_FORTIFY_SOURCE" DEBUG RELWITHDEBINFO)
|
||||
ENDIF()
|
||||
|
||||
# enable security hardening features, like most distributions do
|
||||
# in our benchmarks that costs about ~1% of performance, depending on the load
|
||||
IF(CMAKE_C_COMPILER_VERSION VERSION_LESS "4.6" OR WITH_ASAN OR WITH_UBSAN)
|
||||
SET(security_default OFF)
|
||||
ELSE()
|
||||
SET(security_default ON)
|
||||
ENDIF()
|
||||
OPTION(SECURITY_HARDENED "Use security-enhancing compiler features (stack protector, relro, etc)" ${security_default})
|
||||
IF(SECURITY_HARDENED)
|
||||
IF(WITH_ASAN OR WITH_UBSAN)
|
||||
MESSAGE(FATAL_ERROR "WITH_ASAN/WITH_UBSAN and SECURITY_HARDENED are mutually exclusive")
|
||||
ENDIF()
|
||||
OPTION(SECURITY_HARDENED "Use security-enhancing compiler features (stack protector, relro, etc)" ON)
|
||||
IF(SECURITY_HARDENED AND NOT WITH_ASAN AND NOT WITH_UBSAN AND NOT WITH_TSAN)
|
||||
# security-enhancing flags
|
||||
MY_CHECK_AND_SET_COMPILER_FLAG("-pie -fPIC")
|
||||
MY_CHECK_AND_SET_COMPILER_FLAG("-Wl,-z,relro,-z,now")
|
||||
MY_CHECK_AND_SET_COMPILER_FLAG("-fstack-protector --param=ssp-buffer-size=4")
|
||||
MY_CHECK_AND_SET_COMPILER_FLAG("-D_FORTIFY_SOURCE=2" RELEASE RELWITHDEBINFO)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(wsrep)
|
||||
INCLUDE(cpack_rpm)
|
||||
INCLUDE(cpack_deb)
|
||||
|
||||
# Always enable debug sync for debug builds.
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC")
|
||||
@ -438,10 +431,6 @@ IF(NOT WITHOUT_SERVER)
|
||||
ADD_SUBDIRECTORY(unittest/embedded)
|
||||
ENDIF(WITH_EMBEDDED_SERVER)
|
||||
|
||||
IF(WITH_WSREP)
|
||||
ADD_SUBDIRECTORY(wsrep-lib)
|
||||
ENDIF()
|
||||
|
||||
ADD_SUBDIRECTORY(mysql-test)
|
||||
ADD_SUBDIRECTORY(mysql-test/lib/My/SafeProcess)
|
||||
ADD_SUBDIRECTORY(sql-bench)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
|
||||
Copyright (c) 2009, 2017, MariaDB
|
||||
Copyright (c) 2009, 2019, MariaDB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -1687,6 +1687,7 @@ void abort_not_supported_test(const char *fmt, ...)
|
||||
cur_file->file_name, cur_file->lineno);
|
||||
|
||||
char buff[DIE_BUFF_SIZE];
|
||||
buff[0] = '\0';
|
||||
print_file_stack(buff, buff + sizeof(buff));
|
||||
fprintf(stderr, "%s", buff);
|
||||
|
||||
|
@ -124,6 +124,7 @@ ENDIF()
|
||||
|
||||
IF(UNIX)
|
||||
SET(WITH_EXTRA_CHARSETS all CACHE STRING "")
|
||||
SET(PLUGIN_AUTH_PAM YES)
|
||||
|
||||
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
IF(NOT IGNORE_AIO_CHECK)
|
||||
|
@ -39,6 +39,8 @@ IF(RPM)
|
||||
SET(BUILD_DEPS ${BUILD_DEPS} ${${V}_DEP})
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
IF (BUILD_DEPS)
|
||||
LIST(REMOVE_DUPLICATES BUILD_DEPS)
|
||||
STRING(REPLACE ";" " " CPACK_RPM_BUILDREQUIRES "${BUILD_DEPS}")
|
||||
ENDIF()
|
||||
ENDIF(RPM)
|
||||
|
@ -37,7 +37,8 @@ IF(CMAKE_VERSION VERSION_LESS "3.6.0")
|
||||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${VERSION}-${RPM}-${CMAKE_SYSTEM_PROCESSOR}")
|
||||
ELSE()
|
||||
SET(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
|
||||
SET(CPACK_RPM_DEBUGINFO_PACKAGE ON CACHE INTERNAL "")
|
||||
OPTION(CPACK_RPM_DEBUGINFO_PACKAGE "" ON)
|
||||
MARK_AS_ADVANCED(CPACK_RPM_DEBUGINFO_PACKAGE)
|
||||
ENDIF()
|
||||
|
||||
SET(CPACK_RPM_PACKAGE_RELEASE "1%{?dist}")
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Copyright (c) 2009, 2018, Oracle and/or its affiliates.
|
||||
# Copyright (c) 2011, 2019, MariaDB Corporation
|
||||
# Copyright (c) 2011, 2019, MariaDB Corporation.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -223,7 +223,7 @@ MACRO(MYSQL_ADD_PLUGIN)
|
||||
ELSEIF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
TARGET_LINK_LIBRARIES (${target} mysqld)
|
||||
ENDIF()
|
||||
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT WITH_ASAN AND NOT WITH_TSAN AND NOT WITH_UBSAN)
|
||||
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT WITH_ASAN AND NOT WITH_TSAN AND NOT WITH_UBSAN AND NOT WITH_MSAN)
|
||||
TARGET_LINK_LIBRARIES (${target} "-Wl,--no-undefined")
|
||||
ENDIF()
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#
|
||||
# Galera library does not compile with windows
|
||||
#
|
||||
IF (NOT WITHOUT_SERVER)
|
||||
IF(UNIX)
|
||||
SET(with_wsrep_default ON)
|
||||
ELSE()
|
||||
@ -57,4 +58,10 @@ Then restart the build.
|
||||
endif()
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/wsrep-lib/include)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/wsrep-lib/wsrep-API/v26)
|
||||
|
||||
SET(old_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
|
||||
SET(BUILD_SHARED_LIBS OFF)
|
||||
ADD_SUBDIRECTORY(wsrep-lib)
|
||||
SET(BUILD_SHARED_LIBS ${old_BUILD_SHARED_LIBS})
|
||||
ENDIF()
|
||||
ENDIF(NOT WITHOUT_SERVER)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates.
|
||||
Copyright (C) 2000, 2017, MariaDB Corporation Ab
|
||||
Copyright (C) 2000, 2019, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -35,6 +35,7 @@ struct _db_stack_frame_ {
|
||||
};
|
||||
|
||||
struct _db_code_state_;
|
||||
extern MYSQL_PLUGIN_IMPORT my_bool my_assert;
|
||||
extern my_bool _dbug_on_;
|
||||
extern my_bool _db_keyword_(struct _db_code_state_ *, const char *, int);
|
||||
extern int _db_explain_(struct _db_code_state_ *cs, char *buf, size_t len);
|
||||
@ -103,7 +104,10 @@ extern int (*dbug_sanity)(void);
|
||||
#define DBUG_END() _db_end_ ()
|
||||
#define DBUG_LOCK_FILE _db_lock_file_()
|
||||
#define DBUG_UNLOCK_FILE _db_unlock_file_()
|
||||
#define DBUG_ASSERT(A) do { if (!(A)) { _db_flush_(); assert(A); }} while (0)
|
||||
#define DBUG_ASSERT(A) do { if (!(A)) { _db_flush_(); \
|
||||
if (my_assert) assert(A); \
|
||||
else fprintf(stderr, "%s:%d: assert: %s\n", __FILE__, __LINE__, #A); \
|
||||
}} while (0)
|
||||
#define DBUG_SLOW_ASSERT(A) DBUG_ASSERT(A)
|
||||
#define DBUG_ASSERT_EXISTS
|
||||
#define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len))
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2001, 2013, Oracle and/or its affiliates.
|
||||
Copyright (c) 2009, 2017, MariaDB Corporation
|
||||
Copyright (c) 2009, 2019, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -1037,6 +1037,19 @@ typedef ulong myf; /* Type of MyFlags in my_funcs */
|
||||
#define reg16 register
|
||||
#endif
|
||||
|
||||
/*
|
||||
MYSQL_PLUGIN_IMPORT macro is used to export mysqld data
|
||||
(i.e variables) for usage in storage engine loadable plugins.
|
||||
Outside of Windows, it is dummy.
|
||||
*/
|
||||
#ifndef MYSQL_PLUGIN_IMPORT
|
||||
#if (defined(_WIN32) && defined(MYSQL_DYNAMIC_PLUGIN))
|
||||
#define MYSQL_PLUGIN_IMPORT __declspec(dllimport)
|
||||
#else
|
||||
#define MYSQL_PLUGIN_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <my_dbug.h>
|
||||
|
||||
/* Some helper macros */
|
||||
@ -1163,19 +1176,6 @@ typedef struct { const char *dli_fname, dli_fbase; } Dl_info;
|
||||
#endif
|
||||
#endif /* !defined(__func__) */
|
||||
|
||||
/*
|
||||
MYSQL_PLUGIN_IMPORT macro is used to export mysqld data
|
||||
(i.e variables) for usage in storage engine loadable plugins.
|
||||
Outside of Windows, it is dummy.
|
||||
*/
|
||||
#ifndef MYSQL_PLUGIN_IMPORT
|
||||
#if (defined(_WIN32) && defined(MYSQL_DYNAMIC_PLUGIN))
|
||||
#define MYSQL_PLUGIN_IMPORT __declspec(dllimport)
|
||||
#else
|
||||
#define MYSQL_PLUGIN_IMPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Defines that are unique to the embedded version of MySQL */
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
|
||||
Copyright (c) 2010, 2017, MariaDB Corporation.
|
||||
Copyright (c) 2010, 2019, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -266,6 +266,7 @@ extern ulong my_sync_count;
|
||||
extern uint mysys_usage_id;
|
||||
extern int32 my_file_opened;
|
||||
extern my_bool my_init_done, my_thr_key_mysys_exists;
|
||||
extern MYSQL_PLUGIN_IMPORT my_bool my_assert;
|
||||
extern my_bool my_assert_on_error;
|
||||
extern myf my_global_flags; /* Set to MY_WME for more error messages */
|
||||
/* Point to current my_message() */
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
C_MODE_START
|
||||
|
||||
extern ulonglong log_10_int[20];
|
||||
extern MYSQL_PLUGIN_IMPORT ulonglong log_10_int[20];
|
||||
extern uchar days_in_month[];
|
||||
|
||||
#define MY_TIME_T_MAX LONG_MAX
|
||||
|
@ -51,11 +51,9 @@ extern struct my_print_error_service_st {
|
||||
#define my_printv_error(A,B,C,D) my_print_error_service->my_printv_error_func(A,B,C,D)
|
||||
|
||||
#else
|
||||
#ifndef MY_ERROR_DEFINED
|
||||
extern void my_error(unsigned int nr, unsigned long MyFlags, ...);
|
||||
extern void my_printf_error(unsigned int my_err, const char *format, unsigned long MyFlags, ...);
|
||||
extern void my_printv_error(unsigned int error, const char *format, unsigned long MyFlags,va_list ap);
|
||||
#endif /* MY_ERROR_DEFINED */
|
||||
#endif /* MYSQL_DYNAMIC_PLUGIN */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Submodule libmariadb updated: ed3a91c139...7de639518f
@ -455,6 +455,16 @@ INSERT INTO t1(id, dept, age, name) VALUES
|
||||
(4011, 'cs7', 10, 'rs4'), (4012, 'cs8', 20, 'rs4'), (4019, 'cs9', 10, 'rs5'),
|
||||
(4020, 'cs10', 20, 'rs5'),(4027, 'cs11', 10, 'rs6'),(4028, 'cs12', 20, 'rs6');
|
||||
|
||||
set
|
||||
@tmp_uss=@@use_stat_tables,
|
||||
@tmp_occ=@@optimizer_use_condition_selectivity;
|
||||
set
|
||||
use_stat_tables='preferably',
|
||||
optimizer_use_condition_selectivity=4;
|
||||
|
||||
analyze table t1 persistent for all;
|
||||
flush tables;
|
||||
|
||||
EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
|
||||
SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
|
||||
DELETE FROM t1;
|
||||
@ -464,6 +474,9 @@ EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
|
||||
SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
|
||||
|
||||
DROP TABLE t1;
|
||||
set
|
||||
use_stat_tables=@tmp_uss,
|
||||
optimizer_use_condition_selectivity=@tmp_occ;
|
||||
|
||||
--source include/innodb_rollback_on_timeout.inc
|
||||
|
||||
|
@ -18,7 +18,7 @@ insert t1 values (20101211030405.789e0);
|
||||
insert ignore t1 values (99991231235959e1);
|
||||
select * from t1;
|
||||
--replace_regex /121000/121094/ /457000/457031/ /789000/789062/
|
||||
select truncate(a, 6) from t1; # Field::val_real()
|
||||
select cast(a AS double(30,6)) from t1; # Field::val_real()
|
||||
select a DIV 1 from t1; # Field::val_int()
|
||||
select group_concat(distinct a) from t1; # Field::cmp()
|
||||
alter table t1 engine=innodb;
|
||||
|
@ -32,8 +32,8 @@ if (IS_WINDOWS){
|
||||
my $list= `handle.exe -? -accepteula 2>&1`;
|
||||
foreach my $line (split('\n', $list))
|
||||
{
|
||||
$handle_exe= "$1.$2"
|
||||
if ($line =~ /Handle v([0-9]*)\.([0-9]*)/);
|
||||
$handle_exe= "$2.$3"
|
||||
if ($line =~ /(Nth|H)andle v([0-9]*)\.([0-9]*)/);
|
||||
}
|
||||
if ($handle_exe){
|
||||
print "Found handle.exe version $handle_exe\n";
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (c) 2008, 2012, Oracle and/or its affiliates
|
||||
Copyright (c) 2019, MariaDB Corporation.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -219,6 +220,7 @@ int main(int argc, char* const argv[] )
|
||||
sigemptyset(&sa.sa_mask);
|
||||
|
||||
sa_abort.sa_handler= handle_abort;
|
||||
sa_abort.sa_flags= 0;
|
||||
sigemptyset(&sa_abort.sa_mask);
|
||||
/* Install signal handlers */
|
||||
sigaction(SIGTERM, &sa,NULL);
|
||||
|
@ -376,13 +376,13 @@ SELECT * FROM t1 WHERE a IN ( SELECT a FROM t2 );
|
||||
a b
|
||||
EXPLAIN SELECT * FROM t1 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
|
||||
ANALYZE SELECT * FROM t1 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 4.00 100.00 0.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 4.00 100.00 100.00
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 0.00 100.00 100.00
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00
|
||||
#------------------------------------------------------------------------
|
||||
# I/R/U/D/S on the inner view
|
||||
@ -491,14 +491,14 @@ SELECT * FROM v1 WHERE a IN ( SELECT a FROM t2 );
|
||||
a b
|
||||
EXPLAIN SELECT * FROM v1 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
|
||||
ANALYZE SELECT * FROM v1 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 8.00 100.00 0.00 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 8.00 100.00 0.00 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 NULL 100.00 NULL
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 NULL 100.00 NULL
|
||||
#------------------------------------------------------------------------
|
||||
# I/R/U/D/S on the outer view
|
||||
# Expectation: Can run everything
|
||||
@ -598,14 +598,14 @@ SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
a b
|
||||
EXPLAIN SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 12 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
|
||||
ANALYZE SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 12 12.00 100.00 0.00 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 12 12.00 100.00 0.00 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 NULL 100.00 NULL
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 NULL 100.00 NULL
|
||||
|
||||
#========================================================================
|
||||
# Test: Grant INSERT on the table
|
||||
@ -1591,14 +1591,14 @@ SELECT * FROM v1 WHERE a IN ( SELECT a FROM t2 );
|
||||
a b
|
||||
EXPLAIN SELECT * FROM v1 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
|
||||
ANALYZE SELECT * FROM v1 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 4.00 100.00 0.00 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 4.00 100.00 0.00 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 NULL 100.00 NULL
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 NULL 100.00 NULL
|
||||
#------------------------------------------------------------------------
|
||||
# I/R/U/D/S on the outer view
|
||||
# Expectation: Can run everything: SELECT access to the column `a`
|
||||
@ -1708,14 +1708,14 @@ SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
a b
|
||||
EXPLAIN SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
|
||||
ANALYZE SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 8.00 100.00 0.00 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 8.00 100.00 0.00 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 NULL 100.00 NULL
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 NULL 100.00 NULL
|
||||
|
||||
#========================================================================
|
||||
# Test: Grant SELECT, INSERT, UPDATE, DELETE on the table
|
||||
@ -1940,14 +1940,14 @@ SELECT * FROM v1 WHERE a IN ( SELECT a FROM t2 );
|
||||
a b
|
||||
EXPLAIN SELECT * FROM v1 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
|
||||
ANALYZE SELECT * FROM v1 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 4.00 100.00 0.00 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 4.00 100.00 0.00 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 NULL 100.00 NULL
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 NULL 100.00 NULL
|
||||
#------------------------------------------------------------------------
|
||||
# I/R/U/D/S on the outer view
|
||||
# Expectation: Can run everything
|
||||
@ -2048,14 +2048,14 @@ SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
a b
|
||||
EXPLAIN SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
|
||||
ANALYZE SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 8.00 100.00 0.00 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 8.00 100.00 0.00 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 NULL 100.00 NULL
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 NULL 100.00 NULL
|
||||
|
||||
#########################################################################
|
||||
# Inner view permission tests
|
||||
@ -2697,14 +2697,14 @@ SELECT * FROM v1 WHERE a IN ( SELECT a FROM t2 );
|
||||
a b
|
||||
EXPLAIN SELECT * FROM v1 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 14 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 14 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
|
||||
ANALYZE SELECT * FROM v1 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 14 14.00 100.00 0.00 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 14 14.00 100.00 0.00 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 NULL 100.00 NULL
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 NULL 100.00 NULL
|
||||
#------------------------------------------------------------------------
|
||||
# I/R/U/D/S on the outer view
|
||||
# Expectation: Can run everything
|
||||
@ -2804,14 +2804,14 @@ SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
a b
|
||||
EXPLAIN SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 18 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
|
||||
ANALYZE SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 18 18.00 100.00 0.00 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 18 18.00 100.00 0.00 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 NULL 100.00 NULL
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 NULL 100.00 NULL
|
||||
|
||||
#========================================================================
|
||||
# Test: Grant INSERT on the inner view
|
||||
@ -3987,14 +3987,14 @@ SELECT * FROM v1 WHERE a IN ( SELECT a FROM t2 );
|
||||
a b
|
||||
EXPLAIN SELECT * FROM v1 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 35 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 35 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
|
||||
ANALYZE SELECT * FROM v1 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 35 35.00 100.00 0.00 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 35 35.00 100.00 0.00 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 NULL 100.00 NULL
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 NULL 100.00 NULL
|
||||
#------------------------------------------------------------------------
|
||||
# I/R/U/D/S on the outer view
|
||||
# Expectation: Can run everything
|
||||
@ -4094,14 +4094,14 @@ SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
a b
|
||||
EXPLAIN SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 39 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 39 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
|
||||
ANALYZE SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 39 39.00 100.00 0.00 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 39 39.00 100.00 0.00 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 NULL 100.00 NULL
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 NULL 100.00 NULL
|
||||
|
||||
#########################################################################
|
||||
# Outer view permission tests
|
||||
@ -4614,14 +4614,14 @@ SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
a b
|
||||
EXPLAIN SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 39 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 39 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
|
||||
ANALYZE SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 39 39.00 100.00 0.00 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 39 39.00 100.00 0.00 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 NULL 100.00 NULL
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 NULL 100.00 NULL
|
||||
|
||||
#========================================================================
|
||||
# Test: Grant INSERT on the outer view
|
||||
@ -5221,14 +5221,14 @@ SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
a b
|
||||
EXPLAIN SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 44 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 44 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
|
||||
ANALYZE SELECT * FROM v2 WHERE a IN ( SELECT a FROM t2 );
|
||||
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 3.00 100.00 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 44 44.00 100.00 0.00 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 3.00 100.00 100.00 Using where
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 44 44.00 100.00 0.00 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 NULL 100.00 NULL
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 NULL 100.00 NULL
|
||||
disconnect con1;
|
||||
connection default;
|
||||
DROP USER 'privtest'@localhost;
|
||||
|
@ -129,6 +129,61 @@ t CREATE TABLE `t` (
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP table test.t;
|
||||
SET @@SQL_MODE=@OLD_SQL_MODE;
|
||||
#
|
||||
# MDEV-16932 - ASAN heap-use-after-free in my_charlen_utf8 /
|
||||
# my_well_formed_char_length_utf8 on 2nd execution of SP with
|
||||
# ALTER trying to add bad CHECK
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
CREATE PROCEDURE sp() ALTER TABLE t1 ADD CONSTRAINT CHECK (b > 0);
|
||||
CALL sp;
|
||||
ERROR 42S22: Unknown column 'b' in 'CHECK'
|
||||
CALL sp;
|
||||
ERROR 42S22: Unknown column 'b' in 'CHECK'
|
||||
CALL sp;
|
||||
ERROR 42S22: Unknown column 'b' in 'CHECK'
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
alter table t1 add column b int;
|
||||
CALL sp;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) DEFAULT NULL,
|
||||
CONSTRAINT `CONSTRAINT_1` CHECK (`b` > 0)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
CALL sp;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) DEFAULT NULL,
|
||||
CONSTRAINT `CONSTRAINT_1` CHECK (`b` > 0),
|
||||
CONSTRAINT `CONSTRAINT_2` CHECK (`b` > 0)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP PROCEDURE sp;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a INT);
|
||||
CREATE PROCEDURE sp() ALTER TABLE t1 ADD CONSTRAINT CHECK (b > 0);
|
||||
CALL sp;
|
||||
ERROR 42S22: Unknown column 'b' in 'CHECK'
|
||||
alter table t1 add column b int, add constraint check (b < 10);
|
||||
CALL sp;
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL,
|
||||
`b` int(11) DEFAULT NULL,
|
||||
CONSTRAINT `CONSTRAINT_1` CHECK (`b` < 10),
|
||||
CONSTRAINT `CONSTRAINT_2` CHECK (`b` > 0)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP PROCEDURE sp;
|
||||
DROP TABLE t1;
|
||||
# End of 10.2 tests
|
||||
create table t1 (a int check (a>10)) select 100 as 'a';
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
|
@ -116,6 +116,43 @@ SHOW CREATE TABLE t;
|
||||
DROP table test.t;
|
||||
SET @@SQL_MODE=@OLD_SQL_MODE;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-16932 - ASAN heap-use-after-free in my_charlen_utf8 /
|
||||
--echo # my_well_formed_char_length_utf8 on 2nd execution of SP with
|
||||
--echo # ALTER trying to add bad CHECK
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a INT);
|
||||
CREATE PROCEDURE sp() ALTER TABLE t1 ADD CONSTRAINT CHECK (b > 0);
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
CALL sp;
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
CALL sp;
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
CALL sp;
|
||||
show create table t1;
|
||||
alter table t1 add column b int;
|
||||
CALL sp;
|
||||
show create table t1;
|
||||
CALL sp;
|
||||
show create table t1;
|
||||
# Cleanup
|
||||
DROP PROCEDURE sp;
|
||||
DROP TABLE t1;
|
||||
|
||||
CREATE TABLE t1 (a INT);
|
||||
CREATE PROCEDURE sp() ALTER TABLE t1 ADD CONSTRAINT CHECK (b > 0);
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
CALL sp;
|
||||
alter table t1 add column b int, add constraint check (b < 10);
|
||||
CALL sp;
|
||||
show create table t1;
|
||||
# Cleanup
|
||||
DROP PROCEDURE sp;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo # End of 10.2 tests
|
||||
|
||||
#
|
||||
# Check that we don't lose constraints as part of CREATE ... SELECT
|
||||
#
|
||||
|
@ -1159,9 +1159,9 @@ with cte as
|
||||
union
|
||||
(select a from t1 where a < 2);
|
||||
a
|
||||
7
|
||||
5
|
||||
4
|
||||
5
|
||||
7
|
||||
1
|
||||
prepare stmt from "with cte as
|
||||
(select a from t1 where a between 4 and 7 group by a)
|
||||
@ -1170,15 +1170,15 @@ union
|
||||
(select a from t1 where a < 2)";
|
||||
execute stmt;
|
||||
a
|
||||
7
|
||||
5
|
||||
4
|
||||
5
|
||||
7
|
||||
1
|
||||
execute stmt;
|
||||
a
|
||||
7
|
||||
5
|
||||
4
|
||||
5
|
||||
7
|
||||
1
|
||||
deallocate prepare stmt;
|
||||
with cte as
|
||||
@ -1188,9 +1188,9 @@ union
|
||||
(select a from cte where exists( select a from t1 where cte.a=t1.a ));
|
||||
a
|
||||
1
|
||||
7
|
||||
5
|
||||
4
|
||||
5
|
||||
7
|
||||
prepare stmt from "with cte as
|
||||
(select a from t1 where a between 4 and 7 group by a)
|
||||
(select a from t1 where a < 2)
|
||||
@ -1199,15 +1199,15 @@ union
|
||||
execute stmt;
|
||||
a
|
||||
1
|
||||
7
|
||||
5
|
||||
4
|
||||
5
|
||||
7
|
||||
execute stmt;
|
||||
a
|
||||
1
|
||||
7
|
||||
5
|
||||
4
|
||||
5
|
||||
7
|
||||
deallocate prepare stmt;
|
||||
with cte as
|
||||
(select a from t1 where a between 4 and 7)
|
||||
|
@ -2180,13 +2180,13 @@ CREATE TABLE t1 (a TIMESTAMP(3));
|
||||
INSERT INTO t1 VALUES ('2001-01-01 10:20:30.999');
|
||||
SELECT CAST(COALESCE(a,a) AS SIGNED) AS c1, CAST(COALESCE(a,a) AS DECIMAL(25,3)) AS c2, ROUND(COALESCE(a,a)) AS c2 FROM t1;
|
||||
c1 c2 c2
|
||||
20010101102030 20010101102030.999 20010101102031
|
||||
20010101102030 20010101102030.999 2001-01-01 10:20:31
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a TIME(3));
|
||||
INSERT INTO t1 VALUES ('10:20:30.999');
|
||||
SELECT CAST(COALESCE(a,a) AS SIGNED) AS c1, CAST(COALESCE(a,a) AS DECIMAL(25,3)) AS c2, ROUND(COALESCE(a,a)) AS c2 FROM t1;
|
||||
c1 c2 c2
|
||||
102030 102030.999 102031
|
||||
102030 102030.999 10:20:31
|
||||
DROP TABLE t1;
|
||||
SELECT
|
||||
CAST(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1,
|
||||
|
@ -1608,7 +1608,8 @@ EXPLAIN SELECT 1 FROM t2 WHERE a IN
|
||||
(SELECT a FROM t1 USE INDEX (i2) IGNORE INDEX (i2));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index a a 5 NULL 4 Using index
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 144 Using where; FirstMatch(t2)
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t1 ALL NULL NULL NULL NULL 144
|
||||
SET optimizer_switch=@save_optimizer_switch;
|
||||
DROP TABLE t1, t2;
|
||||
CREATE TABLE t1(
|
||||
|
@ -558,8 +558,9 @@ where exists (select 1 from t2, t3
|
||||
where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
1 PRIMARY t3 ALL a,b NULL NULL NULL 1002 Range checked for each record (index map: 0x3); FirstMatch(t1)
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2
|
||||
2 MATERIALIZED t3 ALL a,b NULL NULL NULL 1002 Range checked for each record (index map: 0x3)
|
||||
select * from t1
|
||||
where exists (select 1 from t2, t3
|
||||
where t2.a=t1.a and (t3.a=t2.b or t3.b=t2.b or t3.b=t2.b+1));
|
||||
|
@ -732,8 +732,8 @@ SELECT a FROM t1 AS t, t2
|
||||
WHERE c = a AND b IN (SELECT b FROM t1, t2 WHERE b = t.b);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t index a,b b 7 NULL 10 Using index
|
||||
1 PRIMARY t1 ref b b 3 test.t.b 2 Using index
|
||||
1 PRIMARY t2 index NULL PRIMARY 4 NULL 11 Using index; FirstMatch(t)
|
||||
1 PRIMARY t1 ref b b 3 test.t.b 2 Using index; Start temporary
|
||||
1 PRIMARY t2 index NULL PRIMARY 4 NULL 11 Using index; End temporary; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t.a 1 Using index
|
||||
SELECT a FROM t1 AS t, t2
|
||||
WHERE c = a AND b IN (SELECT b FROM t1, t2 WHERE b = t.b);
|
||||
@ -745,8 +745,8 @@ SELECT a FROM t1 AS t, t2
|
||||
WHERE c = a AND b IN (SELECT b FROM t1, t2 WHERE b = t.b);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t index a,b b 7 NULL 10 Using index
|
||||
1 PRIMARY t1 ref b b 3 test.t.b 2 Using index
|
||||
1 PRIMARY t2 index NULL PRIMARY 4 NULL 11 Using index; FirstMatch(t)
|
||||
1 PRIMARY t1 ref b b 3 test.t.b 2 Using index; Start temporary
|
||||
1 PRIMARY t2 index NULL PRIMARY 4 NULL 11 Using index; End temporary; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t.a 1 Using index
|
||||
SELECT a FROM t1 AS t, t2
|
||||
WHERE c = a AND b IN (SELECT b FROM t1, t2 WHERE b = t.b);
|
||||
|
@ -385,3 +385,15 @@ SET debug_dbug="+d,test_completely_invisible,test_invisible_index";
|
||||
CREATE TABLE t2 LIKE t1;
|
||||
SET debug_dbug= DEFAULT;
|
||||
DROP TABLE t1, t2;
|
||||
#
|
||||
# MDEV-20210
|
||||
# If you have an INVISIBLE VIRTUAL column, SHOW CREATE TABLE doesn't list it as INVISIBLE
|
||||
#
|
||||
CREATE TABLE t1 (i INT, v int GENERATED ALWAYS AS (1) VIRTUAL INVISIBLE);
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`i` int(11) DEFAULT NULL,
|
||||
`v` int(11) GENERATED ALWAYS AS (1) VIRTUAL INVISIBLE
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1;
|
||||
|
@ -281,3 +281,12 @@ SET debug_dbug="+d,test_completely_invisible,test_invisible_index";
|
||||
CREATE TABLE t2 LIKE t1;
|
||||
SET debug_dbug= DEFAULT;
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-20210
|
||||
--echo # If you have an INVISIBLE VIRTUAL column, SHOW CREATE TABLE doesn't list it as INVISIBLE
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (i INT, v int GENERATED ALWAYS AS (1) VIRTUAL INVISIBLE);
|
||||
SHOW CREATE TABLE t1;
|
||||
DROP TABLE t1;
|
||||
|
@ -2935,6 +2935,332 @@ NULL NULL NULL 9
|
||||
NULL NULL NULL 5
|
||||
drop table t1,t2,t3,t4,s1,s2;
|
||||
#
|
||||
# MDEV-20265: Mix of comma joins with JOIN expressions
|
||||
# (correction of the fix for MDEV-19421)
|
||||
# MDEV-20330: duplicate
|
||||
#
|
||||
create table t1 (a int);
|
||||
insert into t1 values (7), (5), (3);
|
||||
create table t2 (a int);
|
||||
insert into t2 values (5), (1), (7);
|
||||
create table t3 (a int);
|
||||
insert into t3 values (2), (7), (3);
|
||||
create table t4 (a int);
|
||||
insert into t4 values (4), (7), (9), (5);
|
||||
create table t5 (a int);
|
||||
insert into t5 values (3), (7), (9), (2);
|
||||
explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
|
||||
from t1, t2 join t3 left join t4 on t3.a=t4.a;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` left join `test`.`t4` on(`test`.`t4`.`a` = `test`.`t3`.`a`) where 1
|
||||
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
|
||||
from t1, t2 join t3 left join t4 on t3.a=t4.a;
|
||||
t1_a t2_a t3_a t4_a
|
||||
7 5 7 7
|
||||
5 5 7 7
|
||||
3 5 7 7
|
||||
7 1 7 7
|
||||
5 1 7 7
|
||||
3 1 7 7
|
||||
7 7 7 7
|
||||
5 7 7 7
|
||||
3 7 7 7
|
||||
7 5 2 NULL
|
||||
5 5 2 NULL
|
||||
3 5 2 NULL
|
||||
7 1 2 NULL
|
||||
5 1 2 NULL
|
||||
3 1 2 NULL
|
||||
7 7 2 NULL
|
||||
5 7 2 NULL
|
||||
3 7 2 NULL
|
||||
7 5 3 NULL
|
||||
5 5 3 NULL
|
||||
3 5 3 NULL
|
||||
7 1 3 NULL
|
||||
5 1 3 NULL
|
||||
3 1 3 NULL
|
||||
7 7 3 NULL
|
||||
5 7 3 NULL
|
||||
3 7 3 NULL
|
||||
explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
|
||||
from t1, t2 join t3 right join t4 on t3.a=t4.a;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` join `test`.`t4` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t3`.`a` = `test`.`t4`.`a`) where 1
|
||||
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
|
||||
from t1, t2 join t3 right join t4 on t3.a=t4.a;
|
||||
t1_a t2_a t3_a t4_a
|
||||
7 5 7 7
|
||||
5 5 7 7
|
||||
3 5 7 7
|
||||
7 1 7 7
|
||||
5 1 7 7
|
||||
3 1 7 7
|
||||
7 7 7 7
|
||||
5 7 7 7
|
||||
3 7 7 7
|
||||
7 NULL NULL 4
|
||||
5 NULL NULL 4
|
||||
3 NULL NULL 4
|
||||
7 NULL NULL 9
|
||||
5 NULL NULL 9
|
||||
3 NULL NULL 9
|
||||
7 NULL NULL 5
|
||||
5 NULL NULL 5
|
||||
3 NULL NULL 5
|
||||
explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
|
||||
from t1, t2 join t3 join t4 left join t5 on t4.a=t5.a;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (incremental, BNL join)
|
||||
1 SIMPLE t5 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a`,`test`.`t5`.`a` AS `t5_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` left join `test`.`t5` on(`test`.`t5`.`a` = `test`.`t4`.`a`) where 1
|
||||
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
|
||||
from t1, t2 join t3 join t4 left join t5 on t4.a=t5.a;
|
||||
t1_a t2_a t3_a t4_a t5_a
|
||||
7 5 2 7 7
|
||||
5 5 2 7 7
|
||||
3 5 2 7 7
|
||||
7 1 2 7 7
|
||||
5 1 2 7 7
|
||||
3 1 2 7 7
|
||||
7 7 2 7 7
|
||||
5 7 2 7 7
|
||||
3 7 2 7 7
|
||||
7 5 7 7 7
|
||||
5 5 7 7 7
|
||||
3 5 7 7 7
|
||||
7 1 7 7 7
|
||||
5 1 7 7 7
|
||||
3 1 7 7 7
|
||||
7 7 7 7 7
|
||||
5 7 7 7 7
|
||||
3 7 7 7 7
|
||||
7 5 3 7 7
|
||||
5 5 3 7 7
|
||||
3 5 3 7 7
|
||||
7 1 3 7 7
|
||||
5 1 3 7 7
|
||||
3 1 3 7 7
|
||||
7 7 3 7 7
|
||||
5 7 3 7 7
|
||||
3 7 3 7 7
|
||||
7 5 2 9 9
|
||||
5 5 2 9 9
|
||||
3 5 2 9 9
|
||||
7 1 2 9 9
|
||||
5 1 2 9 9
|
||||
3 1 2 9 9
|
||||
7 7 2 9 9
|
||||
5 7 2 9 9
|
||||
3 7 2 9 9
|
||||
7 5 7 9 9
|
||||
5 5 7 9 9
|
||||
3 5 7 9 9
|
||||
7 1 7 9 9
|
||||
5 1 7 9 9
|
||||
3 1 7 9 9
|
||||
7 7 7 9 9
|
||||
5 7 7 9 9
|
||||
3 7 7 9 9
|
||||
7 5 3 9 9
|
||||
5 5 3 9 9
|
||||
3 5 3 9 9
|
||||
7 1 3 9 9
|
||||
5 1 3 9 9
|
||||
3 1 3 9 9
|
||||
7 7 3 9 9
|
||||
5 7 3 9 9
|
||||
3 7 3 9 9
|
||||
7 5 2 4 NULL
|
||||
5 5 2 4 NULL
|
||||
3 5 2 4 NULL
|
||||
7 1 2 4 NULL
|
||||
5 1 2 4 NULL
|
||||
3 1 2 4 NULL
|
||||
7 7 2 4 NULL
|
||||
5 7 2 4 NULL
|
||||
3 7 2 4 NULL
|
||||
7 5 7 4 NULL
|
||||
5 5 7 4 NULL
|
||||
3 5 7 4 NULL
|
||||
7 1 7 4 NULL
|
||||
5 1 7 4 NULL
|
||||
3 1 7 4 NULL
|
||||
7 7 7 4 NULL
|
||||
5 7 7 4 NULL
|
||||
3 7 7 4 NULL
|
||||
7 5 3 4 NULL
|
||||
5 5 3 4 NULL
|
||||
3 5 3 4 NULL
|
||||
7 1 3 4 NULL
|
||||
5 1 3 4 NULL
|
||||
3 1 3 4 NULL
|
||||
7 7 3 4 NULL
|
||||
5 7 3 4 NULL
|
||||
3 7 3 4 NULL
|
||||
7 5 2 5 NULL
|
||||
5 5 2 5 NULL
|
||||
3 5 2 5 NULL
|
||||
7 1 2 5 NULL
|
||||
5 1 2 5 NULL
|
||||
3 1 2 5 NULL
|
||||
7 7 2 5 NULL
|
||||
5 7 2 5 NULL
|
||||
3 7 2 5 NULL
|
||||
7 5 7 5 NULL
|
||||
5 5 7 5 NULL
|
||||
3 5 7 5 NULL
|
||||
7 1 7 5 NULL
|
||||
5 1 7 5 NULL
|
||||
3 1 7 5 NULL
|
||||
7 7 7 5 NULL
|
||||
5 7 7 5 NULL
|
||||
3 7 7 5 NULL
|
||||
7 5 3 5 NULL
|
||||
5 5 3 5 NULL
|
||||
3 5 3 5 NULL
|
||||
7 1 3 5 NULL
|
||||
5 1 3 5 NULL
|
||||
3 1 3 5 NULL
|
||||
7 7 3 5 NULL
|
||||
5 7 3 5 NULL
|
||||
3 7 3 5 NULL
|
||||
explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
|
||||
from t1, t2 join t3 join t4 right join t5 on t4.a=t5.a;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
|
||||
1 SIMPLE t5 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a`,`test`.`t5`.`a` AS `t5_a` from `test`.`t1` join `test`.`t5` left join (`test`.`t2` join `test`.`t3` join `test`.`t4`) on(`test`.`t4`.`a` = `test`.`t5`.`a`) where 1
|
||||
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
|
||||
from t1, t2 join t3 join t4 right join t5 on t4.a=t5.a;
|
||||
t1_a t2_a t3_a t4_a t5_a
|
||||
7 5 2 7 7
|
||||
5 5 2 7 7
|
||||
3 5 2 7 7
|
||||
7 1 2 7 7
|
||||
5 1 2 7 7
|
||||
3 1 2 7 7
|
||||
7 7 2 7 7
|
||||
5 7 2 7 7
|
||||
3 7 2 7 7
|
||||
7 5 7 7 7
|
||||
5 5 7 7 7
|
||||
3 5 7 7 7
|
||||
7 1 7 7 7
|
||||
5 1 7 7 7
|
||||
3 1 7 7 7
|
||||
7 7 7 7 7
|
||||
5 7 7 7 7
|
||||
3 7 7 7 7
|
||||
7 5 3 7 7
|
||||
5 5 3 7 7
|
||||
3 5 3 7 7
|
||||
7 1 3 7 7
|
||||
5 1 3 7 7
|
||||
3 1 3 7 7
|
||||
7 7 3 7 7
|
||||
5 7 3 7 7
|
||||
3 7 3 7 7
|
||||
7 5 2 9 9
|
||||
5 5 2 9 9
|
||||
3 5 2 9 9
|
||||
7 1 2 9 9
|
||||
5 1 2 9 9
|
||||
3 1 2 9 9
|
||||
7 7 2 9 9
|
||||
5 7 2 9 9
|
||||
3 7 2 9 9
|
||||
7 5 7 9 9
|
||||
5 5 7 9 9
|
||||
3 5 7 9 9
|
||||
7 1 7 9 9
|
||||
5 1 7 9 9
|
||||
3 1 7 9 9
|
||||
7 7 7 9 9
|
||||
5 7 7 9 9
|
||||
3 7 7 9 9
|
||||
7 5 3 9 9
|
||||
5 5 3 9 9
|
||||
3 5 3 9 9
|
||||
7 1 3 9 9
|
||||
5 1 3 9 9
|
||||
3 1 3 9 9
|
||||
7 7 3 9 9
|
||||
5 7 3 9 9
|
||||
3 7 3 9 9
|
||||
7 NULL NULL NULL 3
|
||||
5 NULL NULL NULL 3
|
||||
3 NULL NULL NULL 3
|
||||
7 NULL NULL NULL 2
|
||||
5 NULL NULL NULL 2
|
||||
3 NULL NULL NULL 2
|
||||
explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
|
||||
from t1 left join t2 on t1.a=t2.a, t3 join t4 right join t5 on t4.a=t5.a;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t5 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (incremental, BNL join)
|
||||
1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a`,`test`.`t5`.`a` AS `t5_a` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) join `test`.`t5` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t4`.`a` = `test`.`t5`.`a`) where 1
|
||||
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
|
||||
from t1 left join t2 on t1.a=t2.a, t3 join t4 right join t5 on t4.a=t5.a;
|
||||
t1_a t2_a t3_a t4_a t5_a
|
||||
5 5 2 7 7
|
||||
7 7 2 7 7
|
||||
3 NULL 2 7 7
|
||||
5 5 7 7 7
|
||||
7 7 7 7 7
|
||||
3 NULL 7 7 7
|
||||
5 5 3 7 7
|
||||
7 7 3 7 7
|
||||
3 NULL 3 7 7
|
||||
5 5 2 9 9
|
||||
7 7 2 9 9
|
||||
3 NULL 2 9 9
|
||||
5 5 7 9 9
|
||||
7 7 7 9 9
|
||||
3 NULL 7 9 9
|
||||
5 5 3 9 9
|
||||
7 7 3 9 9
|
||||
3 NULL 3 9 9
|
||||
5 5 NULL NULL 3
|
||||
7 7 NULL NULL 3
|
||||
3 NULL NULL NULL 3
|
||||
5 5 NULL NULL 2
|
||||
7 7 NULL NULL 2
|
||||
3 NULL NULL NULL 2
|
||||
drop table t1,t2,t3,t4,t5;
|
||||
select a.a
|
||||
from (select 1 as a) a,
|
||||
(select 2 as b) b
|
||||
cross join
|
||||
(select 3 as c) c
|
||||
left join
|
||||
(select 4 as d) d
|
||||
on 1;
|
||||
a
|
||||
1
|
||||
#
|
||||
# End of MariaDB 5.5 tests
|
||||
#
|
||||
#
|
||||
|
@ -1614,6 +1614,65 @@ eval $q;
|
||||
|
||||
drop table t1,t2,t3,t4,s1,s2;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-20265: Mix of comma joins with JOIN expressions
|
||||
--echo # (correction of the fix for MDEV-19421)
|
||||
--echo # MDEV-20330: duplicate
|
||||
--echo #
|
||||
|
||||
create table t1 (a int);
|
||||
insert into t1 values (7), (5), (3);
|
||||
create table t2 (a int);
|
||||
insert into t2 values (5), (1), (7);
|
||||
create table t3 (a int);
|
||||
insert into t3 values (2), (7), (3);
|
||||
create table t4 (a int);
|
||||
insert into t4 values (4), (7), (9), (5);
|
||||
create table t5 (a int);
|
||||
insert into t5 values (3), (7), (9), (2);
|
||||
|
||||
|
||||
let $q=
|
||||
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
|
||||
from t1, t2 join t3 left join t4 on t3.a=t4.a;
|
||||
eval explain extended $q;
|
||||
eval $q;
|
||||
|
||||
let $q=
|
||||
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
|
||||
from t1, t2 join t3 right join t4 on t3.a=t4.a;
|
||||
eval explain extended $q;
|
||||
eval $q;
|
||||
|
||||
let $q=
|
||||
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
|
||||
from t1, t2 join t3 join t4 left join t5 on t4.a=t5.a;
|
||||
eval explain extended $q;
|
||||
eval $q;
|
||||
|
||||
let $q=
|
||||
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
|
||||
from t1, t2 join t3 join t4 right join t5 on t4.a=t5.a;
|
||||
eval explain extended $q;
|
||||
eval $q;
|
||||
|
||||
let $q=
|
||||
select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a, t5.a as t5_a
|
||||
from t1 left join t2 on t1.a=t2.a, t3 join t4 right join t5 on t4.a=t5.a;
|
||||
eval explain extended $q;
|
||||
eval $q;
|
||||
|
||||
drop table t1,t2,t3,t4,t5;
|
||||
|
||||
select a.a
|
||||
from (select 1 as a) a,
|
||||
(select 2 as b) b
|
||||
cross join
|
||||
(select 3 as c) c
|
||||
left join
|
||||
(select 4 as d) d
|
||||
on 1;
|
||||
|
||||
--echo #
|
||||
--echo # End of MariaDB 5.5 tests
|
||||
--echo #
|
||||
|
@ -1462,4 +1462,19 @@ t1 CREATE TABLE `t1` (
|
||||
KEY `pk` (`pk`,`a`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-19705: Assertion `tmp >= 0' failed in best_access_path
|
||||
#
|
||||
CREATE TABLE t1 (d varchar(10)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('a'),('q');
|
||||
CREATE TABLE t2 (f varchar(10), a2 datetime, b int, a1 varchar(1024), pk int NOT NULL, PRIMARY KEY (pk), UNIQUE KEY (f,a1,a2), KEY f2 (f(4),a2)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES ('aaa','1985-09-06',-163,'s',1),('bbb','1995-01-05',3,'pucaz',2),('ccc','0000-00-00',NULL,'help',3),('ddd',NULL,618,'v',4),('eee','1995-12-20',410,'m',5),('ffq','1976-06-12 20:02:56',NULL,'POKNC',6),('dddd','0000-00-00',-328,'hgsu',7);
|
||||
explain
|
||||
SELECT t2.b FROM t1 JOIN t2 ON t1.d = t2.f WHERE t2.pk >= 20;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 range PRIMARY,f,f2 PRIMARY 4 NULL 1 Using index condition
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
SELECT t2.b FROM t1 JOIN t2 ON t1.d = t2.f WHERE t2.pk >= 20;
|
||||
b
|
||||
drop table t1,t2;
|
||||
set @@GLOBAL.max_allowed_packet= @allowed_packet;
|
||||
|
@ -542,4 +542,18 @@ alter table t1 modify a varchar(1000);
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-19705: Assertion `tmp >= 0' failed in best_access_path
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (d varchar(10)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('a'),('q');
|
||||
|
||||
CREATE TABLE t2 (f varchar(10), a2 datetime, b int, a1 varchar(1024), pk int NOT NULL, PRIMARY KEY (pk), UNIQUE KEY (f,a1,a2), KEY f2 (f(4),a2)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES ('aaa','1985-09-06',-163,'s',1),('bbb','1995-01-05',3,'pucaz',2),('ccc','0000-00-00',NULL,'help',3),('ddd',NULL,618,'v',4),('eee','1995-12-20',410,'m',5),('ffq','1976-06-12 20:02:56',NULL,'POKNC',6),('dddd','0000-00-00',-328,'hgsu',7);
|
||||
explain
|
||||
SELECT t2.b FROM t1 JOIN t2 ON t1.d = t2.f WHERE t2.pk >= 20;
|
||||
SELECT t2.b FROM t1 JOIN t2 ON t1.d = t2.f WHERE t2.pk >= 20;
|
||||
drop table t1,t2;
|
||||
|
||||
set @@GLOBAL.max_allowed_packet= @allowed_packet;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -536,4 +536,35 @@ explain select * from t0 A, one_k B where A.a=B.b and B.a<800;
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
drop table t0, one_k;
|
||||
|
||||
--echo #
|
||||
--echo # Assertion `to_len >= 8' failed in convert_to_printable
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 ( a blob, KEY (a(255)));
|
||||
insert into t1 values ('foo'), ('bar');
|
||||
|
||||
EXPLAIN SELECT * FROM t1 WHERE a= REPEAT('a', 0);
|
||||
SELECT * FROM t1 WHERE a= REPEAT('a', 0);
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # Test for Semi-Join table pullout element
|
||||
--echo #
|
||||
create table t1 (a int primary key, b int);
|
||||
insert into t1 (a) values (1),(2),(3),(4),(5);
|
||||
|
||||
create table t2 (a int primary key, b int);
|
||||
insert into t2 (a) values (1),(2),(3),(4),(5);
|
||||
|
||||
create table t3 (a int);
|
||||
insert into t3 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
|
||||
|
||||
explain
|
||||
select * from t3 where (a,a) in (select t1.a, t2.a from t1, t2 where t1.b=t2.b);
|
||||
|
||||
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.semijoin_table_pullout')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
|
||||
|
||||
drop table t1,t2,t3;
|
||||
set optimizer_trace='enabled=off';
|
||||
|
@ -46,12 +46,12 @@ a b
|
||||
2 5
|
||||
explain extended select * from t1 where a in (1,2);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`_col_1`
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1
|
||||
explain extended select * from t1
|
||||
where a in
|
||||
(
|
||||
@ -59,12 +59,12 @@ select *
|
||||
from (values (1),(2)) as tvc_0
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1`
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1
|
||||
# AND-condition with IN-predicates in WHERE-part
|
||||
select * from t1
|
||||
where a in (1,2) and
|
||||
@ -90,15 +90,15 @@ explain extended select * from t1
|
||||
where a in (1,2) and
|
||||
b in (1,5);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery4> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
4 MATERIALIZED <derived5> ALL NULL NULL NULL NULL 2 100.00
|
||||
2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
|
||||
5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) semi join ((values (1),(5)) `tvc_1`) where `test`.`t1`.`b` = `tvc_1`.`_col_1`
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) semi join ((values (1),(5)) `tvc_1`) where 1
|
||||
explain extended select * from t1
|
||||
where a in
|
||||
(
|
||||
@ -111,15 +111,15 @@ select *
|
||||
from (values (1),(5)) as tvc_1
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery4> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
4 MATERIALIZED <derived5> ALL NULL NULL NULL NULL 2 100.00
|
||||
2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
|
||||
5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) semi join ((values (1),(5)) `tvc_1`) where `test`.`t1`.`b` = `tvc_1`.`1`
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) semi join ((values (1),(5)) `tvc_1`) where 1
|
||||
# subquery with IN-predicate
|
||||
select * from t1
|
||||
where a in
|
||||
@ -206,12 +206,12 @@ from t1
|
||||
where a in (1,2)
|
||||
) as dr_table;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
3 MATERIALIZED <derived4> ALL NULL NULL NULL NULL 2 100.00
|
||||
4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`_col_1`
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1
|
||||
explain extended select * from
|
||||
(
|
||||
select *
|
||||
@ -224,12 +224,12 @@ as tvc_0
|
||||
)
|
||||
) as dr_table;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
3 MATERIALIZED <derived4> ALL NULL NULL NULL NULL 2 100.00
|
||||
4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1`
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1
|
||||
# non-recursive CTE with IN-predicate
|
||||
with tvc_0 as
|
||||
(
|
||||
@ -265,12 +265,12 @@ where a in (1,2)
|
||||
)
|
||||
select * from tvc_0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
3 MATERIALIZED <derived4> ALL NULL NULL NULL NULL 2 100.00
|
||||
4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 with tvc_0 as (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` in (1,2))/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`_col_1`
|
||||
Note 1003 with tvc_0 as (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` in (1,2))/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1
|
||||
explain extended select * from
|
||||
(
|
||||
select *
|
||||
@ -283,12 +283,12 @@ as tvc_0
|
||||
)
|
||||
) as dr_table;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
3 MATERIALIZED <derived4> ALL NULL NULL NULL NULL 2 100.00
|
||||
4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1`
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1
|
||||
# VIEW with IN-predicate
|
||||
create view v1 as
|
||||
select *
|
||||
@ -316,20 +316,20 @@ a b
|
||||
2 5
|
||||
explain extended select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
3 MATERIALIZED <derived4> ALL NULL NULL NULL NULL 2 100.00
|
||||
4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`_col_1`
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1
|
||||
explain extended select * from v2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
3 MATERIALIZED <derived4> ALL NULL NULL NULL NULL 2 100.00
|
||||
4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1`
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1
|
||||
drop view v1,v2;
|
||||
# subselect defined by derived table with IN-predicate
|
||||
select * from t1
|
||||
@ -519,12 +519,12 @@ a b
|
||||
1 2
|
||||
explain extended select * from t1 where (a,b) in ((1,2),(3,4));
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1 100.00
|
||||
2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1,2),(3,4)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`_col_1` and `test`.`t1`.`b` = `tvc_0`.`_col_2`
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1,2),(3,4)) `tvc_0`) where 1
|
||||
set @@in_predicate_conversion_threshold= 2;
|
||||
# trasformation works for the one IN predicate and doesn't work for the other
|
||||
set @@in_predicate_conversion_threshold= 5;
|
||||
@ -538,12 +538,12 @@ explain extended select * from t2
|
||||
where (a,b) in ((1,2),(8,9)) and
|
||||
(a,c) in ((1,3),(8,0),(5,1));
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 100.00
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1 100.00
|
||||
2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` semi join ((values (1,3),(8,0),(5,1)) `tvc_0`) where `test`.`t2`.`a` = `tvc_0`.`_col_1` and `test`.`t2`.`c` = `tvc_0`.`_col_2` and (`tvc_0`.`_col_1`,`test`.`t2`.`b`) in (<cache>((1,2)),<cache>((8,9)))
|
||||
Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` semi join ((values (1,3),(8,0),(5,1)) `tvc_0`) where (`test`.`t2`.`a`,`test`.`t2`.`b`) in (<cache>((1,2)),<cache>((8,9)))
|
||||
set @@in_predicate_conversion_threshold= 2;
|
||||
#
|
||||
# mdev-14281: conversion of NOT IN predicate into subquery predicate
|
||||
|
@ -987,4 +987,31 @@ a MAX(b)
|
||||
SHOW status LIKE 'handler_read_key';
|
||||
Variable_name Value
|
||||
Handler_read_key 2
|
||||
#
|
||||
# MDEV-18501 Partition pruning doesn't work for historical queries
|
||||
#
|
||||
set time_zone= '+00:00';
|
||||
create or replace table t1 (d datetime(6))
|
||||
partition by range (unix_timestamp(d)) (
|
||||
partition p0 values less than (1),
|
||||
partition p1 values less than (maxvalue));
|
||||
ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed
|
||||
# DECIMAL functions are now allowed, partitioning is done by integer part
|
||||
create or replace table t1 (d timestamp(6))
|
||||
partition by range (unix_timestamp(d)) (
|
||||
partition p0 values less than (946684801),
|
||||
partition p1 values less than (maxvalue));
|
||||
insert into t1 values
|
||||
# go to p0
|
||||
('2000-01-01 00:00:00'),
|
||||
('2000-01-01 00:00:00.000001'),
|
||||
# goes to p1
|
||||
('2000-01-01 00:00:01');
|
||||
select * from t1 partition (p0);
|
||||
d
|
||||
2000-01-01 00:00:00.000000
|
||||
2000-01-01 00:00:00.000001
|
||||
select * from t1 partition (p1);
|
||||
d
|
||||
2000-01-01 00:00:01.000000
|
||||
DROP TABLE t1, t2;
|
||||
|
@ -973,4 +973,31 @@ SELECT a, MAX(b) FROM t2 WHERE a IN (10, 100) GROUP BY a;
|
||||
--echo # Should be no more than 4 reads.
|
||||
SHOW status LIKE 'handler_read_key';
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-18501 Partition pruning doesn't work for historical queries
|
||||
--echo #
|
||||
set time_zone= '+00:00';
|
||||
let $ts= `select unix_timestamp('2000-01-01 00:00:00') + 1`;
|
||||
|
||||
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
|
||||
create or replace table t1 (d datetime(6))
|
||||
partition by range (unix_timestamp(d)) (
|
||||
partition p0 values less than (1),
|
||||
partition p1 values less than (maxvalue));
|
||||
|
||||
--echo # DECIMAL functions are now allowed, partitioning is done by integer part
|
||||
eval create or replace table t1 (d timestamp(6))
|
||||
partition by range (unix_timestamp(d)) (
|
||||
partition p0 values less than ($ts),
|
||||
partition p1 values less than (maxvalue));
|
||||
|
||||
insert into t1 values
|
||||
# go to p0
|
||||
('2000-01-01 00:00:00'),
|
||||
('2000-01-01 00:00:00.000001'),
|
||||
# goes to p1
|
||||
('2000-01-01 00:00:01');
|
||||
select * from t1 partition (p0);
|
||||
select * from t1 partition (p1);
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
|
@ -2179,7 +2179,7 @@ count(*)
|
||||
6
|
||||
explain extended select count(*) from t1 where a in (22,83,11) and b=2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ref b,a b 5 const 59 55.93 Using where
|
||||
1 SIMPLE t1 ref b,a b 5 const 59 3.30 Using where
|
||||
Warnings:
|
||||
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (22,83,11)
|
||||
select * from t1 where a in (22,83,11) and b=2;
|
||||
@ -2196,7 +2196,7 @@ count(*)
|
||||
6
|
||||
explain extended select count(*) from t1 where a in (22,83,11) and b=2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ref|filter b,a b|a 5|5 const 59 (3%) 55.93 Using where; Using rowid filter
|
||||
1 SIMPLE t1 ref|filter b,a b|a 5|5 const 59 (3%) 3.30 Using where; Using rowid filter
|
||||
Warnings:
|
||||
Note 1003 select count(0) AS `count(*)` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (22,83,11)
|
||||
select * from t1 where a in (22,83,11) and b=2;
|
||||
|
@ -1637,3 +1637,37 @@ set @@use_stat_tables= @save_use_stat_tables;
|
||||
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
drop table t1;
|
||||
drop function f1;
|
||||
#
|
||||
# MDEV-19834 Selectivity of an equality condition discounted twice
|
||||
#
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
set @@use_stat_tables='preferably';
|
||||
create table t1 (a int, b int, key (b), key (a));
|
||||
insert into t1
|
||||
select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000;
|
||||
analyze table t1 ;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Engine-independent statistics collected
|
||||
test.t1 analyze status Table is already up to date
|
||||
# Check what info the optimizer has about selectivities
|
||||
explain extended select * from t1 use index () where a in (17,51,5);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 3.90 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`a` in (17,51,5)
|
||||
explain extended select * from t1 use index () where b=2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 5.47 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`b` = 2
|
||||
# Now, the equality is used for ref access, while the range condition
|
||||
# gives selectivity data
|
||||
explain extended select * from t1 where a in (17,51,5) and b=2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ref|filter b,a b|a 5|5 const 58 (3%) 2.90 Using where; Using rowid filter
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (17,51,5)
|
||||
drop table t1;
|
||||
set use_stat_tables= @save_use_stat_tables;
|
||||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
# End of 10.1 tests
|
||||
|
@ -1,4 +1,5 @@
|
||||
--source include/have_stat_tables.inc
|
||||
--source include/have_sequence.inc
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t0,t1,t2,t3;
|
||||
@ -1104,3 +1105,26 @@ set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectiv
|
||||
drop table t1;
|
||||
drop function f1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-19834 Selectivity of an equality condition discounted twice
|
||||
--echo #
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
set @@use_stat_tables='preferably';
|
||||
create table t1 (a int, b int, key (b), key (a));
|
||||
insert into t1
|
||||
select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000;
|
||||
analyze table t1 ;
|
||||
|
||||
--echo # Check what info the optimizer has about selectivities
|
||||
explain extended select * from t1 use index () where a in (17,51,5);
|
||||
explain extended select * from t1 use index () where b=2;
|
||||
|
||||
--echo # Now, the equality is used for ref access, while the range condition
|
||||
--echo # gives selectivity data
|
||||
explain extended select * from t1 where a in (17,51,5) and b=2;
|
||||
drop table t1;
|
||||
|
||||
set use_stat_tables= @save_use_stat_tables;
|
||||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
--echo # End of 10.1 tests
|
||||
|
||||
|
@ -1647,6 +1647,40 @@ set @@use_stat_tables= @save_use_stat_tables;
|
||||
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
drop table t1;
|
||||
drop function f1;
|
||||
#
|
||||
# MDEV-19834 Selectivity of an equality condition discounted twice
|
||||
#
|
||||
set @@optimizer_use_condition_selectivity=4;
|
||||
set @@use_stat_tables='preferably';
|
||||
create table t1 (a int, b int, key (b), key (a));
|
||||
insert into t1
|
||||
select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000;
|
||||
analyze table t1 ;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Engine-independent statistics collected
|
||||
test.t1 analyze status OK
|
||||
# Check what info the optimizer has about selectivities
|
||||
explain extended select * from t1 use index () where a in (17,51,5);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 3.90 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`a` in (17,51,5)
|
||||
explain extended select * from t1 use index () where b=2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 5.47 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`b` = 2
|
||||
# Now, the equality is used for ref access, while the range condition
|
||||
# gives selectivity data
|
||||
explain extended select * from t1 where a in (17,51,5) and b=2;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ref|filter b,a b|a 5|5 const 59 (3%) 2.90 Using where; Using rowid filter
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (17,51,5)
|
||||
drop table t1;
|
||||
set use_stat_tables= @save_use_stat_tables;
|
||||
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
|
||||
# End of 10.1 tests
|
||||
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
|
||||
set @tmp_ust= @@use_stat_tables;
|
||||
set @tmp_oucs= @@optimizer_use_condition_selectivity;
|
||||
|
@ -5703,8 +5703,8 @@ EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE EXISTS (SELECT a FROM t2 USE INDEX() WHERE t2.a = t1.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
|
||||
SELECT * FROM t1
|
||||
WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a);
|
||||
@ -5714,8 +5714,8 @@ EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 index idx idx 5 NULL 3 Using index
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
|
@ -1139,8 +1139,8 @@ create table t3 (a int);
|
||||
insert into t3 select A.a + 10*B.a from t0 A, t0 B;
|
||||
explain select * from t3 where a in (select kp1 from t1 where kp1<20);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range kp1 kp1 5 NULL 48 Using where; Using index; LooseScan
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY t1 ref kp1 kp1 5 test.t3.a 1 Using index; FirstMatch(t3)
|
||||
create table t4 (pk int primary key);
|
||||
insert into t4 select a from t3;
|
||||
explain select * from t3 where a in (select t1.kp1 from t1,t4 where kp1<20
|
||||
@ -1276,12 +1276,12 @@ insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B;
|
||||
create table t2 as select * from t1;
|
||||
explain select * from t2 where a in (select b from t1 where a=3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ref a a 5 const 8 Using index; LooseScan
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY t1 ref a a 10 const,test.t2.a 1 Using index; FirstMatch(t2)
|
||||
explain select * from t2 where (b,a) in (select a,b from t1 where a=3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ref a a 5 const 8 Using index; LooseScan
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY t1 ref a a 10 const,test.t2.a 1 Using index; FirstMatch(t2)
|
||||
drop table t1,t2;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
create table t1 (a int, b int);
|
||||
@ -1339,9 +1339,9 @@ insert into t2 select * from t2;
|
||||
explain select * from t1 where (a,b,c) in (select X.a, Y.a, Z.a from t2 X, t2 Y, t2 Z where X.b=33);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY X ALL NULL NULL NULL NULL 6 Using where
|
||||
1 PRIMARY Y ALL NULL NULL NULL NULL 6 Using where
|
||||
1 PRIMARY Z ALL NULL NULL NULL NULL 6 Using where; FirstMatch(t1)
|
||||
1 PRIMARY X ALL NULL NULL NULL NULL 6 Using where; Start temporary; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY Y ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY Z ALL NULL NULL NULL NULL 6 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
drop table t0,t1,t2;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
|
@ -1149,8 +1149,8 @@ create table t3 (a int);
|
||||
insert into t3 select A.a + 10*B.a from t0 A, t0 B;
|
||||
explain select * from t3 where a in (select kp1 from t1 where kp1<20);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range kp1 kp1 5 NULL 48 Using where; Using index; LooseScan
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY t1 ref kp1 kp1 5 test.t3.a 1 Using index; FirstMatch(t3)
|
||||
create table t4 (pk int primary key);
|
||||
insert into t4 select a from t3;
|
||||
explain select * from t3 where a in (select t1.kp1 from t1,t4 where kp1<20
|
||||
@ -1286,12 +1286,12 @@ insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B;
|
||||
create table t2 as select * from t1;
|
||||
explain select * from t2 where a in (select b from t1 where a=3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ref a a 5 const 8 Using index; LooseScan
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY t1 ref a a 10 const,test.t2.a 1 Using index; FirstMatch(t2)
|
||||
explain select * from t2 where (b,a) in (select a,b from t1 where a=3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ref a a 5 const 8 Using index; LooseScan
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY t1 ref a a 10 const,test.t2.a 1 Using index; FirstMatch(t2)
|
||||
drop table t1,t2;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
create table t1 (a int, b int);
|
||||
@ -1348,10 +1348,10 @@ create table t2 as select a as a, a as b from t0 where a < 3;
|
||||
insert into t2 select * from t2;
|
||||
explain select * from t1 where (a,b,c) in (select X.a, Y.a, Z.a from t2 X, t2 Y, t2 Z where X.b=33);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY X ALL NULL NULL NULL NULL 6 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY Y ALL NULL NULL NULL NULL 6 Using where; Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY Z ALL NULL NULL NULL NULL 6 Using where; FirstMatch(t1); Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY X hash_ALL NULL #hash#$hj 5 test.t1.a 6 Using where; Start temporary; Using join buffer (flat, BNLH join)
|
||||
1 PRIMARY Y hash_ALL NULL #hash#$hj 5 test.t1.b 6 Using where; Using join buffer (incremental, BNLH join)
|
||||
1 PRIMARY Z hash_ALL NULL #hash#$hj 5 test.t1.c 6 Using where; End temporary; Using join buffer (incremental, BNLH join)
|
||||
drop table t0,t1,t2;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
|
@ -1510,8 +1510,8 @@ set @@optimizer_switch=@optimizer_switch_local_default;
|
||||
SET @@optimizer_switch='semijoin=on,materialization=on';
|
||||
EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 7 func,func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
|
||||
COUNT(*)
|
||||
@ -2437,8 +2437,8 @@ INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
|
||||
explain
|
||||
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 hash_ALL NULL #hash#$hj 4 test.t2.i1 9 Using where; Using join buffer (flat, BNLH join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 9
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
|
||||
1
|
||||
@ -2450,8 +2450,8 @@ alter table t1 add key(id);
|
||||
explain
|
||||
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index
|
||||
1 PRIMARY t1 index id id 4 NULL 9 Using index
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
|
||||
1
|
||||
@ -2507,8 +2507,8 @@ INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
|
||||
CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2;
|
||||
explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index
|
||||
1 PRIMARY t1 index id id 4 NULL 9 Using index
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
|
||||
1
|
||||
|
@ -5683,9 +5683,9 @@ WHERE (ot1.a,ot4.a) IN (SELECT it2.a,it3.a
|
||||
FROM it2,it3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY ot1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY ot4 ALL NULL NULL NULL NULL 8 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY it2 ALL NULL NULL NULL NULL 4 Using where
|
||||
1 PRIMARY it3 ALL NULL NULL NULL NULL 6 Using where; FirstMatch(ot4)
|
||||
1 PRIMARY it2 ALL NULL NULL NULL NULL 4 Using where; Start temporary; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY it3 ALL NULL NULL NULL NULL 6 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY ot4 ALL NULL NULL NULL NULL 8 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
DROP TABLE IF EXISTS ot1, ot4, it2, it3;
|
||||
#
|
||||
# Bug#729039: NULL keys used to evaluate subquery
|
||||
@ -5712,8 +5712,8 @@ EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index idx idx 5 NULL 3 Using index; LooseScan
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where
|
||||
1 PRIMARY t2 ref idx idx 5 test.t1.a 2 Using index; FirstMatch(t1)
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# BUG#752992: Wrong results for a subquery with 'semijoin=on'
|
||||
|
@ -5709,8 +5709,8 @@ EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE EXISTS (SELECT a FROM t2 USE INDEX() WHERE t2.a = t1.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
|
||||
SELECT * FROM t1
|
||||
WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a);
|
||||
@ -5720,8 +5720,8 @@ EXPLAIN
|
||||
SELECT * FROM t1
|
||||
WHERE EXISTS (SELECT a FROM t2 WHERE t2.a = t1.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 index idx idx 5 NULL 3 Using index
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
|
@ -729,8 +729,8 @@ SELECT int_key FROM ot1
|
||||
WHERE int_nokey IN (SELECT it2.int_key
|
||||
FROM it1 LEFT JOIN it2 ON it2.datetime_key);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 10
|
||||
1 PRIMARY ot1 ALL NULL NULL NULL NULL 20 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY ot1 ALL NULL NULL NULL NULL 20
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED it1 index NULL int_key 4 NULL 2 Using index
|
||||
2 MATERIALIZED it2 ALL int_key,datetime_key NULL NULL NULL 20 Using where
|
||||
DROP TABLE ot1, it1, it2;
|
||||
@ -972,11 +972,11 @@ SELECT `varchar_key` , `varchar_nokey`
|
||||
FROM t1
|
||||
WHERE `varchar_nokey` < 'n' XOR `pk` ) ;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 15 100.00
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1 100.00
|
||||
2 MATERIALIZED t1 ALL varchar_key NULL NULL NULL 15 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`varchar_nokey` = `test`.`t1`.`varchar_key` and `test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_key` and (`test`.`t1`.`varchar_key` < 'n' xor `test`.`t1`.`pk`)
|
||||
Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`varchar_nokey` = `test`.`t1`.`varchar_key` and (`test`.`t1`.`varchar_key` < 'n' xor `test`.`t1`.`pk`)
|
||||
SELECT varchar_nokey
|
||||
FROM t2
|
||||
WHERE ( `varchar_nokey` , `varchar_nokey` ) IN (
|
||||
@ -1246,8 +1246,8 @@ INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1);
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index k k 10 NULL 4 Using where; Using index; LooseScan
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 index k k 10 NULL 4 Using where; Using index; Start temporary
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0);
|
||||
i
|
||||
1
|
||||
@ -1757,8 +1757,8 @@ insert into t3 values('three'),( 'four');
|
||||
insert into t3 values('three'),( 'four');
|
||||
explain select * from t3 where t3.b in (select t2.b from t1 left join t2 on t1.a=t2.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 8
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 10 func 1
|
||||
2 MATERIALIZED t1 ALL NULL NULL NULL NULL 2
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
select * from t3 where t3.b in (select t2.b from t1 left join t2 on t1.a=t2.a);
|
||||
@ -1991,12 +1991,13 @@ CREATE VIEW v4 AS SELECT DISTINCT f2 FROM t4 ;
|
||||
explain extended
|
||||
SELECT * FROM t1 NATURAL LEFT JOIN (t2, t3) WHERE t2.f3 IN (SELECT * FROM t4);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
1 PRIMARY t4 ref f2 f2 5 test.t2.f3 2 100.00 Using index; FirstMatch(t2)
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 5 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 index f2 f2 5 NULL 2 100.00 Using index
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3`,`test`.`t3`.`f3` AS `f3` from `test`.`t1` semi join (`test`.`t4`) join `test`.`t2` join `test`.`t3` where `test`.`t4`.`f2` = `test`.`t2`.`f3` and `test`.`t3`.`f1` = `test`.`t1`.`f1` and `test`.`t1`.`f2` = `test`.`t2`.`f2`
|
||||
Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2`,`test`.`t2`.`f3` AS `f3`,`test`.`t3`.`f3` AS `f3` from `test`.`t1` semi join (`test`.`t4`) join `test`.`t2` join `test`.`t3` where `test`.`t3`.`f1` = `test`.`t1`.`f1` and `test`.`t1`.`f2` = `test`.`t2`.`f2`
|
||||
SELECT * FROM t1 NATURAL LEFT JOIN (t2, t3) WHERE t2.f3 IN (SELECT * FROM t4);
|
||||
f1 f2 f3 f3
|
||||
2 0 0 0
|
||||
@ -2495,8 +2496,8 @@ WHERE t1.a = t2.a AND t2.a IN (SELECT b FROM t3 STRAIGHT_JOIN t4);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 1
|
||||
1 PRIMARY t1 ref a a 5 const 1 Using index
|
||||
1 PRIMARY t2 ref a a 5 func 1 Using index
|
||||
1 PRIMARY t2 ref a a 5 const 1 Using index
|
||||
1 PRIMARY t1 ref a a 5 func 1 Using index
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 0
|
||||
SELECT * FROM t1, t2
|
||||
WHERE t1.a = t2.a AND t2.a IN (SELECT b FROM t3 STRAIGHT_JOIN t4);
|
||||
@ -2706,8 +2707,8 @@ a
|
||||
19
|
||||
explain select * from t3 where a in (select kp1 from t1 where kp1<20);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range kp1 kp1 5 NULL 48 Using where; Using index; LooseScan
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY t1 ref kp1 kp1 5 test.t3.a 1 Using index; FirstMatch(t3)
|
||||
drop table t0,t1,t3;
|
||||
set optimizer_switch= @tmp_923246;
|
||||
#
|
||||
@ -2923,8 +2924,8 @@ WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o'
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY alias1 index_merge PRIMARY,col_int_key,col_varchar_key PRIMARY,col_varchar_key 4,4 NULL 2 Using sort_union(PRIMARY,col_varchar_key); Using where
|
||||
1 PRIMARY alias2 ALL col_int_key NULL NULL NULL 12 Range checked for each record (index map: 0x2); FirstMatch(t2)
|
||||
1 PRIMARY alias1 index_merge PRIMARY,col_int_key,col_varchar_key PRIMARY,col_varchar_key 4,4 NULL 2 Using sort_union(PRIMARY,col_varchar_key); Using where; Start temporary
|
||||
1 PRIMARY alias2 ALL col_int_key NULL NULL NULL 12 Range checked for each record (index map: 0x2); End temporary
|
||||
SELECT *
|
||||
FROM t2
|
||||
WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1
|
||||
@ -3264,4 +3265,27 @@ create table t2 (a2 varchar(25)) ;
|
||||
insert into t1 select 'xxx' from dual where 'xxx' in (select a2 from t2);
|
||||
drop table t1,t2;
|
||||
# End of 5.5 test
|
||||
#
|
||||
# MDEV-20109: Optimizer ignores distinct key created for materialized
|
||||
# semi-join subquery when searching for best execution plan
|
||||
#
|
||||
create table t1(a int);
|
||||
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t2(a int);
|
||||
insert into t2 select A.a + B.a* 10 + C.a * 100 from t1 A, t1 B, t1 C;
|
||||
create table t3 (a int);
|
||||
create table t4 (a int);
|
||||
insert into t3 select A.a +1000*B.a from t2 A, t1 B;
|
||||
insert into t4 select floor(rand()*1000) from t2 limit 500;
|
||||
# The following must not use this query plan that does a cross join:
|
||||
# | 1 | PRIMARY | <subquery2> | ALL | distinct_key | ... | 500 | |
|
||||
# | 1 | PRIMARY | t3 | ALL | NULL | ... | 10000 | Using where; Using join buffer (flat, BNL join) |
|
||||
#
|
||||
# Instead, it should use eq_ref on the materialized table.
|
||||
explain select * from t3 where a in (select a from t4);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 10000
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 500
|
||||
drop table t1, t2, t3, t4;
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
|
@ -2940,5 +2940,30 @@ drop table t1,t2;
|
||||
|
||||
--echo # End of 5.5 test
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-20109: Optimizer ignores distinct key created for materialized
|
||||
--echo # semi-join subquery when searching for best execution plan
|
||||
--echo #
|
||||
create table t1(a int);
|
||||
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
|
||||
create table t2(a int);
|
||||
insert into t2 select A.a + B.a* 10 + C.a * 100 from t1 A, t1 B, t1 C;
|
||||
|
||||
create table t3 (a int);
|
||||
create table t4 (a int);
|
||||
insert into t3 select A.a +1000*B.a from t2 A, t1 B;
|
||||
insert into t4 select floor(rand()*1000) from t2 limit 500;
|
||||
|
||||
--echo # The following must not use this query plan that does a cross join:
|
||||
--echo # | 1 | PRIMARY | <subquery2> | ALL | distinct_key | ... | 500 | |
|
||||
--echo # | 1 | PRIMARY | t3 | ALL | NULL | ... | 10000 | Using where; Using join buffer (flat, BNL join) |
|
||||
--echo #
|
||||
--echo # Instead, it should use eq_ref on the materialized table.
|
||||
|
||||
explain select * from t3 where a in (select a from t4);
|
||||
|
||||
drop table t1, t2, t3, t4;
|
||||
|
||||
# The following command must be the last one the file
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
|
@ -131,8 +131,9 @@ set join_buffer_size= @save_join_buffer_size;
|
||||
set max_heap_table_size= @save_max_heap_table_size;
|
||||
explain select * from t1 where a in (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY t2 ref b b 5 test.t1.a 1 Using index; FirstMatch(t1)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 index b b 5 NULL 20 Using index
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
@ -159,8 +160,8 @@ explain select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 22
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 32
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED it ALL NULL NULL NULL NULL 22
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
@ -227,8 +228,8 @@ explain select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 22
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 52
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED it ALL NULL NULL NULL NULL 22
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
@ -730,8 +731,9 @@ alter table t3 add primary key(id), add key(a);
|
||||
The following must use loose index scan over t3, key a:
|
||||
explain select count(a) from t2 where a in ( SELECT a FROM t3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index a a 5 NULL 1000 Using where; Using index
|
||||
1 PRIMARY t3 ref a a 5 test.t2.a 30 Using index; FirstMatch(t2)
|
||||
1 PRIMARY t2 index a a 5 NULL 1000 Using index
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t3 index a a 5 NULL 30000 Using index
|
||||
select count(a) from t2 where a in ( SELECT a FROM t3);
|
||||
count(a)
|
||||
1000
|
||||
@ -757,9 +759,10 @@ c2 in (select 1 from t3, t2) and
|
||||
c1 in (select convert(c6,char(1)) from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t2)
|
||||
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 FirstMatch(t2)
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 FirstMatch((sj-nest))
|
||||
3 MATERIALIZED t2 ALL NULL NULL NULL NULL 1
|
||||
drop table t2, t3;
|
||||
#
|
||||
# BUG#761598: InnoDB: Error: row_search_for_mysql() is called without ha_innobase::external_lock() in maria-5.3
|
||||
@ -810,6 +813,14 @@ CREATE TABLE t2 (f14 int(11) NOT NULL, f12 varchar(1) NOT NULL, KEY (f12,f14)) E
|
||||
INSERT INTO t2 VALUES (6,'y');
|
||||
CREATE TABLE t3 (f12 varchar(1) NOT NULL) ENGINE=InnoDB;
|
||||
INSERT INTO t3 VALUES ('r'),('s'),('t'),('v'),('w'),('x'),('y');
|
||||
analyze table t1,t2,t3 persistent for all;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Engine-independent statistics collected
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status Engine-independent statistics collected
|
||||
test.t2 analyze status OK
|
||||
test.t3 analyze status Engine-independent statistics collected
|
||||
test.t3 analyze status OK
|
||||
# The following must use LooseScan but not join buffering
|
||||
explain
|
||||
SELECT * FROM t3
|
||||
@ -1099,6 +1110,14 @@ INSERT INTO t2 VALUES
|
||||
(9,'d','d'),(10,'s','s'),(11,'r','r'),(12,'m','m'),
|
||||
(13,'b','b'),(14,'x','x'),(15,'g','g'),(16,'p','p'),
|
||||
(17,'q','q'),(18,'w','w'),(19,'d','d');
|
||||
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 t2 persistent for all;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 analyze status Engine-independent statistics collected
|
||||
test.t2 analyze status OK
|
||||
EXPLAIN
|
||||
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
|
||||
WHERE alias3.d IN (
|
||||
@ -1107,11 +1126,11 @@ WHERE alias5.b = alias4.b
|
||||
AND ( alias5.b >= alias3.b OR alias5.c != alias3.c )
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL #
|
||||
1 PRIMARY alias5 index PRIMARY c 4 NULL # Using where; Using index
|
||||
1 PRIMARY alias4 eq_ref PRIMARY,c PRIMARY 4 test.alias5.b # Using where; FirstMatch(alias3)
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL # Using where
|
||||
1 PRIMARY alias4 ref PRIMARY,c c 4 test.alias3.d # Using index
|
||||
1 PRIMARY alias5 eq_ref PRIMARY PRIMARY 4 test.alias4.b # Using where; FirstMatch(alias3)
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
|
||||
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
|
||||
WHERE alias3.d IN (
|
||||
SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
|
||||
@ -1128,11 +1147,11 @@ WHERE alias5.b = alias4.b
|
||||
AND ( alias5.b >= alias3.b OR alias3.c != alias5.c )
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL #
|
||||
1 PRIMARY alias5 index PRIMARY c 4 NULL # Using where; Using index
|
||||
1 PRIMARY alias4 eq_ref PRIMARY,c PRIMARY 4 test.alias5.b # Using where; FirstMatch(alias3)
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL # Using where
|
||||
1 PRIMARY alias4 ref PRIMARY,c c 4 test.alias3.d # Using index
|
||||
1 PRIMARY alias5 eq_ref PRIMARY PRIMARY 4 test.alias4.b # Using where; FirstMatch(alias3)
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
|
||||
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
|
||||
WHERE alias3.d IN (
|
||||
SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
|
||||
|
@ -994,6 +994,7 @@ INSERT INTO t2 VALUES (6,'y');
|
||||
CREATE TABLE t3 (f12 varchar(1) NOT NULL) ENGINE=InnoDB;
|
||||
INSERT INTO t3 VALUES ('r'),('s'),('t'),('v'),('w'),('x'),('y');
|
||||
|
||||
analyze table t1,t2,t3 persistent for all;
|
||||
--echo # The following must use LooseScan but not join buffering
|
||||
|
||||
--replace_column 9 #
|
||||
@ -1225,6 +1226,8 @@ INSERT INTO t2 VALUES
|
||||
(13,'b','b'),(14,'x','x'),(15,'g','g'),(16,'p','p'),
|
||||
(17,'q','q'),(18,'w','w'),(19,'d','d');
|
||||
|
||||
analyze table t1 persistent for all;
|
||||
analyze table t2 persistent for all;
|
||||
--replace_column 9 #
|
||||
EXPLAIN
|
||||
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
|
||||
|
@ -171,9 +171,9 @@ explain select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 22
|
||||
1 PRIMARY ot hash_ALL NULL #hash#$hj 5 test.it.a 32 Using where; Using join buffer (flat, BNLH join)
|
||||
2 MATERIALIZED it ALL NULL NULL NULL NULL 22 Using where
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 32
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED it ALL NULL NULL NULL NULL 22
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
@ -239,9 +239,9 @@ explain select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 22
|
||||
1 PRIMARY ot hash_ALL NULL #hash#$hj 5 test.it.a 52 Using where; Using join buffer (flat, BNLH join)
|
||||
2 MATERIALIZED it ALL NULL NULL NULL NULL 22 Using where
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 52
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED it ALL NULL NULL NULL NULL 22
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
@ -826,6 +826,14 @@ CREATE TABLE t2 (f14 int(11) NOT NULL, f12 varchar(1) NOT NULL, KEY (f12,f14)) E
|
||||
INSERT INTO t2 VALUES (6,'y');
|
||||
CREATE TABLE t3 (f12 varchar(1) NOT NULL) ENGINE=InnoDB;
|
||||
INSERT INTO t3 VALUES ('r'),('s'),('t'),('v'),('w'),('x'),('y');
|
||||
analyze table t1,t2,t3 persistent for all;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Engine-independent statistics collected
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status Engine-independent statistics collected
|
||||
test.t2 analyze status OK
|
||||
test.t3 analyze status Engine-independent statistics collected
|
||||
test.t3 analyze status OK
|
||||
# The following must use LooseScan but not join buffering
|
||||
explain
|
||||
SELECT * FROM t3
|
||||
@ -1115,6 +1123,14 @@ INSERT INTO t2 VALUES
|
||||
(9,'d','d'),(10,'s','s'),(11,'r','r'),(12,'m','m'),
|
||||
(13,'b','b'),(14,'x','x'),(15,'g','g'),(16,'p','p'),
|
||||
(17,'q','q'),(18,'w','w'),(19,'d','d');
|
||||
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 t2 persistent for all;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 analyze status Engine-independent statistics collected
|
||||
test.t2 analyze status OK
|
||||
EXPLAIN
|
||||
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
|
||||
WHERE alias3.d IN (
|
||||
@ -1123,11 +1139,11 @@ WHERE alias5.b = alias4.b
|
||||
AND ( alias5.b >= alias3.b OR alias5.c != alias3.c )
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL #
|
||||
1 PRIMARY alias5 index PRIMARY c 4 NULL # Using where; Using index; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias4 eq_ref PRIMARY,c PRIMARY 4 test.alias5.b # Using where; FirstMatch(alias3); Using join buffer (incremental, BKA join); Key-ordered scan
|
||||
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL # Using where
|
||||
1 PRIMARY alias4 ref PRIMARY,c c 4 test.alias3.d # Using index
|
||||
1 PRIMARY alias5 eq_ref PRIMARY PRIMARY 4 test.alias4.b # Using where; FirstMatch(alias3)
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (incremental, BNL join)
|
||||
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
|
||||
WHERE alias3.d IN (
|
||||
SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
|
||||
@ -1144,11 +1160,11 @@ WHERE alias5.b = alias4.b
|
||||
AND ( alias5.b >= alias3.b OR alias3.c != alias5.c )
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL #
|
||||
1 PRIMARY alias5 index PRIMARY c 4 NULL # Using where; Using index; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias4 eq_ref PRIMARY,c PRIMARY 4 test.alias5.b # Using where; FirstMatch(alias3); Using join buffer (incremental, BKA join); Key-ordered scan
|
||||
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL # Using where
|
||||
1 PRIMARY alias4 ref PRIMARY,c c 4 test.alias3.d # Using index
|
||||
1 PRIMARY alias5 eq_ref PRIMARY PRIMARY 4 test.alias4.b # Using where; FirstMatch(alias3)
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (incremental, BNL join)
|
||||
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
|
||||
WHERE alias3.d IN (
|
||||
SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
|
||||
@ -1410,9 +1426,10 @@ SELECT t3.* FROM t1 JOIN t3 ON t3.b = t1.b
|
||||
WHERE c IN (SELECT t4.b FROM t4 JOIN t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t4 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t3); Using join buffer (incremental, BNL join)
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
1 PRIMARY t1 ref b b 4 test.t3.b 1 Using index
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 1
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
SELECT t3.* FROM t1 JOIN t3 ON t3.b = t1.b
|
||||
WHERE c IN (SELECT t4.b FROM t4 JOIN t2);
|
||||
b c
|
||||
@ -1438,9 +1455,10 @@ EXPLAIN
|
||||
SELECT * FROM t1, t2 WHERE b IN (SELECT a FROM t3, t4 WHERE b = pk);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1
|
||||
1 PRIMARY t4 ALL NULL NULL NULL NULL 1 Using where
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.b 1 Using where; FirstMatch(t2)
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 1 Using where
|
||||
2 MATERIALIZED t3 eq_ref PRIMARY PRIMARY 4 test.t4.b 1
|
||||
SELECT * FROM t1, t2 WHERE b IN (SELECT a FROM t3, t4 WHERE b = pk);
|
||||
pk a b
|
||||
1 6 8
|
||||
|
@ -133,8 +133,9 @@ set join_buffer_size= @save_join_buffer_size;
|
||||
set max_heap_table_size= @save_max_heap_table_size;
|
||||
explain select * from t1 where a in (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
|
||||
1 PRIMARY t2 ref b b 5 test.t1.a 1 Using index; FirstMatch(t1)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 index b b 5 NULL 20 Using index
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
@ -161,8 +162,8 @@ explain select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 22
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 32 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 32
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED it ALL NULL NULL NULL NULL 22
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
@ -229,8 +230,8 @@ explain select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
from t1 ot where a in (select a from t2 it);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 22
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 52 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY ot ALL NULL NULL NULL NULL 52
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED it ALL NULL NULL NULL NULL 22
|
||||
select
|
||||
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z
|
||||
@ -732,8 +733,9 @@ alter table t3 add primary key(id), add key(a);
|
||||
The following must use loose index scan over t3, key a:
|
||||
explain select count(a) from t2 where a in ( SELECT a FROM t3);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index a a 5 NULL 1000 Using where; Using index
|
||||
1 PRIMARY t3 ref a a 5 test.t2.a 30 Using index; FirstMatch(t2)
|
||||
1 PRIMARY t2 index a a 5 NULL 1000 Using index
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t3 index a a 5 NULL 30000 Using index
|
||||
select count(a) from t2 where a in ( SELECT a FROM t3);
|
||||
count(a)
|
||||
1000
|
||||
@ -759,9 +761,10 @@ c2 in (select 1 from t3, t2) and
|
||||
c1 in (select convert(c6,char(1)) from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where; FirstMatch(t2)
|
||||
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 1
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 FirstMatch(t2)
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 FirstMatch((sj-nest))
|
||||
3 MATERIALIZED t2 ALL NULL NULL NULL NULL 1
|
||||
drop table t2, t3;
|
||||
#
|
||||
# BUG#761598: InnoDB: Error: row_search_for_mysql() is called without ha_innobase::external_lock() in maria-5.3
|
||||
@ -812,6 +815,14 @@ CREATE TABLE t2 (f14 int(11) NOT NULL, f12 varchar(1) NOT NULL, KEY (f12,f14)) E
|
||||
INSERT INTO t2 VALUES (6,'y');
|
||||
CREATE TABLE t3 (f12 varchar(1) NOT NULL) ENGINE=InnoDB;
|
||||
INSERT INTO t3 VALUES ('r'),('s'),('t'),('v'),('w'),('x'),('y');
|
||||
analyze table t1,t2,t3 persistent for all;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status Engine-independent statistics collected
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status Engine-independent statistics collected
|
||||
test.t2 analyze status OK
|
||||
test.t3 analyze status Engine-independent statistics collected
|
||||
test.t3 analyze status OK
|
||||
# The following must use LooseScan but not join buffering
|
||||
explain
|
||||
SELECT * FROM t3
|
||||
@ -1101,6 +1112,14 @@ INSERT INTO t2 VALUES
|
||||
(9,'d','d'),(10,'s','s'),(11,'r','r'),(12,'m','m'),
|
||||
(13,'b','b'),(14,'x','x'),(15,'g','g'),(16,'p','p'),
|
||||
(17,'q','q'),(18,'w','w'),(19,'d','d');
|
||||
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 t2 persistent for all;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t2 analyze status Engine-independent statistics collected
|
||||
test.t2 analyze status OK
|
||||
EXPLAIN
|
||||
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
|
||||
WHERE alias3.d IN (
|
||||
@ -1109,11 +1128,11 @@ WHERE alias5.b = alias4.b
|
||||
AND ( alias5.b >= alias3.b OR alias5.c != alias3.c )
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL #
|
||||
1 PRIMARY alias5 index PRIMARY c 4 NULL # Using where; Using index
|
||||
1 PRIMARY alias4 eq_ref PRIMARY,c PRIMARY 4 test.alias5.b # Using where; FirstMatch(alias3)
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL # Using where
|
||||
1 PRIMARY alias4 ref PRIMARY,c c 4 test.alias3.d # Using index
|
||||
1 PRIMARY alias5 eq_ref PRIMARY PRIMARY 4 test.alias4.b # Using where; FirstMatch(alias3)
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
|
||||
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
|
||||
WHERE alias3.d IN (
|
||||
SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
|
||||
@ -1130,11 +1149,11 @@ WHERE alias5.b = alias4.b
|
||||
AND ( alias5.b >= alias3.b OR alias3.c != alias5.c )
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL #
|
||||
1 PRIMARY alias5 index PRIMARY c 4 NULL # Using where; Using index
|
||||
1 PRIMARY alias4 eq_ref PRIMARY,c PRIMARY 4 test.alias5.b # Using where; FirstMatch(alias3)
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL # Using where
|
||||
1 PRIMARY alias4 ref PRIMARY,c c 4 test.alias3.d # Using index
|
||||
1 PRIMARY alias5 eq_ref PRIMARY PRIMARY 4 test.alias4.b # Using where; FirstMatch(alias3)
|
||||
1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join)
|
||||
SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
|
||||
WHERE alias3.d IN (
|
||||
SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
|
||||
@ -1638,12 +1657,12 @@ set optimizer_switch='materialization=on,semijoin=on';
|
||||
EXPLAIN EXTENDED
|
||||
SELECT * FROM t1 WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 = i2 OR 1=2);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 100.00
|
||||
1 PRIMARY t1 hash_ALL NULL #hash#$hj 5 test.t2.i2 5 100.00 Using where; Using join buffer (flat, BNLH join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
2 MATERIALIZED t3 hash_ALL NULL #hash#$hj 5 test.t2.i2 3 100.00 Using where; Using join buffer (flat, BNLH join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where `test`.`t3`.`i3` = `test`.`t2`.`i2` and `test`.`t1`.`i1` = `test`.`t2`.`i2`
|
||||
Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where `test`.`t3`.`i3` = `test`.`t2`.`i2`
|
||||
SELECT * FROM t1 WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 = i2 OR 1=2);
|
||||
i1
|
||||
7
|
||||
@ -1651,12 +1670,12 @@ EXPLAIN EXTENDED
|
||||
SELECT * FROM t1
|
||||
WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 > 0 AND i3 = i2 OR 1=2);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 100.00
|
||||
1 PRIMARY t1 hash_ALL NULL #hash#$hj 5 test.t2.i2 5 100.00 Using where; Using join buffer (flat, BNLH join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
2 MATERIALIZED t3 hash_ALL NULL #hash#$hj 5 test.t2.i2 3 100.00 Using where; Using join buffer (flat, BNLH join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where `test`.`t3`.`i3` = `test`.`t2`.`i2` and `test`.`t1`.`i1` = `test`.`t2`.`i2` and `test`.`t3`.`i3` > 0
|
||||
Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where `test`.`t3`.`i3` = `test`.`t2`.`i2` and `test`.`t3`.`i3` > 0
|
||||
SELECT * FROM t1
|
||||
WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 > 0 AND i3 = i2 OR 1=2);
|
||||
i1
|
||||
@ -1748,8 +1767,8 @@ OR
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t index PRIMARY PRIMARY 4 NULL 13 Using where; Using index
|
||||
2 MATERIALIZED <subquery3> ALL distinct_key NULL NULL NULL 8
|
||||
2 MATERIALIZED A ALL PRIMARY NULL NULL NULL 13 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED A ALL PRIMARY NULL NULL NULL 13
|
||||
2 MATERIALIZED <subquery3> eq_ref distinct_key distinct_key 67 func 1
|
||||
3 MATERIALIZED B range PRIMARY PRIMARY 4 NULL 8 Using where
|
||||
SELECT SQL_NO_CACHE t.id
|
||||
FROM t1 t
|
||||
@ -1914,18 +1933,16 @@ AND t3.id_product IN (SELECT id_product FROM t2 t2_5 WHERE t2_5.id_t2 = 29 OR t2
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 12
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t2_2.id_product 1 Using where; Using index
|
||||
1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 4 func 1 Using where
|
||||
1 PRIMARY t5 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY <subquery6> eq_ref distinct_key distinct_key 4 func 1 Using where
|
||||
1 PRIMARY t4 eq_ref PRIMARY PRIMARY 8 test.t3.id_product,const 1 Using where; Using index
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 Using where
|
||||
1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 4 func 1 Using where
|
||||
1 PRIMARY t2_3 ref id_t2,id_product id_product 5 test.t3.id_product 44 Using index condition; Using where; Start temporary; End temporary
|
||||
1 PRIMARY t2_5 ref id_t2,id_product id_product 5 test.t3.id_product 44 Using index condition; Using where; Start temporary; End temporary
|
||||
1 PRIMARY t5 ALL NULL NULL NULL NULL 18 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t4 eq_ref PRIMARY PRIMARY 8 test.t3.id_product,const 1 Using where; Using index
|
||||
1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 4 func 1 Using where
|
||||
1 PRIMARY t1 index NULL PRIMARY 8 NULL 73 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
3 MATERIALIZED t2_2 ref id_t2,id_product id_t2 5 const 12 Using where
|
||||
5 MATERIALIZED t2_4 range id_t2,id_product id_t2 5 NULL 18 Using index condition; Using where
|
||||
6 MATERIALIZED t2_5 range id_t2,id_product id_t2 5 NULL 31 Using index condition; Using where
|
||||
2 MATERIALIZED t2_1 ref id_t2,id_product id_t2 5 const 51
|
||||
4 MATERIALIZED t2_3 range id_t2,id_product id_t2 5 NULL 33 Using index condition; Using where
|
||||
5 MATERIALIZED t2_4 range id_t2,id_product id_t2 5 NULL 18 Using index condition; Using where
|
||||
set optimizer_switch='rowid_filter=default';
|
||||
drop table t1,t2,t3,t4,t5;
|
||||
set global innodb_stats_persistent= @innodb_stats_persistent_save;
|
||||
|
@ -742,8 +742,8 @@ SELECT int_key FROM ot1
|
||||
WHERE int_nokey IN (SELECT it2.int_key
|
||||
FROM it1 LEFT JOIN it2 ON it2.datetime_key);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 10
|
||||
1 PRIMARY ot1 ALL NULL NULL NULL NULL 20 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY ot1 ALL NULL NULL NULL NULL 20
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED it1 index NULL int_key 4 NULL 2 Using index
|
||||
2 MATERIALIZED it2 ALL int_key,datetime_key NULL NULL NULL 20 Using where; Using join buffer (flat, BNL join)
|
||||
DROP TABLE ot1, it1, it2;
|
||||
@ -985,11 +985,11 @@ SELECT `varchar_key` , `varchar_nokey`
|
||||
FROM t1
|
||||
WHERE `varchar_nokey` < 'n' XOR `pk` ) ;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 15 100.00
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 18 100.00
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1 100.00
|
||||
2 MATERIALIZED t1 ALL varchar_key NULL NULL NULL 15 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`varchar_nokey` = `test`.`t1`.`varchar_key` and `test`.`t2`.`varchar_nokey` = `test`.`t1`.`varchar_key` and (`test`.`t1`.`varchar_key` < 'n' xor `test`.`t1`.`pk`)
|
||||
Note 1003 select `test`.`t2`.`varchar_nokey` AS `varchar_nokey` from `test`.`t2` semi join (`test`.`t1`) where `test`.`t1`.`varchar_nokey` = `test`.`t1`.`varchar_key` and (`test`.`t1`.`varchar_key` < 'n' xor `test`.`t1`.`pk`)
|
||||
SELECT varchar_nokey
|
||||
FROM t2
|
||||
WHERE ( `varchar_nokey` , `varchar_nokey` ) IN (
|
||||
@ -1259,8 +1259,8 @@ INSERT INTO t2 VALUES (1, 0), (1, 1), (2, 0), (2, 1);
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 index k k 10 NULL 4 Using where; Using index; LooseScan
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t2 index k k 10 NULL 4 Using where; Using index; Start temporary
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where; End temporary; Using join buffer (flat, BNL join)
|
||||
SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0);
|
||||
i
|
||||
1
|
||||
@ -1770,8 +1770,8 @@ insert into t3 values('three'),( 'four');
|
||||
insert into t3 values('three'),( 'four');
|
||||
explain select * from t3 where t3.b in (select t2.b from t1 left join t2 on t1.a=t2.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 8
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 10 func 1
|
||||
2 MATERIALIZED t1 ALL NULL NULL NULL NULL 2
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
select * from t3 where t3.b in (select t2.b from t1 left join t2 on t1.a=t2.a);
|
||||
@ -2509,8 +2509,8 @@ WHERE t1.a = t2.a AND t2.a IN (SELECT b FROM t3 STRAIGHT_JOIN t4);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 system NULL NULL NULL NULL 1
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 1
|
||||
1 PRIMARY t1 ref a a 5 const 1 Using index
|
||||
1 PRIMARY t2 ref a a 5 func 1 Using index
|
||||
1 PRIMARY t2 ref a a 5 const 1 Using index
|
||||
1 PRIMARY t1 ref a a 5 func 1 Using index
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 0
|
||||
SELECT * FROM t1, t2
|
||||
WHERE t1.a = t2.a AND t2.a IN (SELECT b FROM t3 STRAIGHT_JOIN t4);
|
||||
@ -2720,8 +2720,8 @@ a
|
||||
19
|
||||
explain select * from t3 where a in (select kp1 from t1 where kp1<20);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 range kp1 kp1 5 NULL 48 Using where; Using index; LooseScan
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 100 Using where
|
||||
1 PRIMARY t1 ref kp1 kp1 5 test.t3.a 1 Using index; FirstMatch(t3)
|
||||
drop table t0,t1,t3;
|
||||
set optimizer_switch= @tmp_923246;
|
||||
#
|
||||
@ -2937,8 +2937,8 @@ WHERE alias1.pk = 58 OR alias1.col_varchar_key = 'o'
|
||||
);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY alias1 index_merge PRIMARY,col_int_key,col_varchar_key PRIMARY,col_varchar_key 4,4 NULL 2 Using sort_union(PRIMARY,col_varchar_key); Using where
|
||||
1 PRIMARY alias2 ALL col_int_key NULL NULL NULL 12 Range checked for each record (index map: 0x2); FirstMatch(t2)
|
||||
1 PRIMARY alias1 index_merge PRIMARY,col_int_key,col_varchar_key PRIMARY,col_varchar_key 4,4 NULL 2 Using sort_union(PRIMARY,col_varchar_key); Using where; Start temporary; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY alias2 ALL col_int_key NULL NULL NULL 12 Range checked for each record (index map: 0x2); End temporary
|
||||
SELECT *
|
||||
FROM t2
|
||||
WHERE (field1) IN (SELECT alias1.col_varchar_nokey AS field1
|
||||
@ -3278,6 +3278,29 @@ create table t2 (a2 varchar(25)) ;
|
||||
insert into t1 select 'xxx' from dual where 'xxx' in (select a2 from t2);
|
||||
drop table t1,t2;
|
||||
# End of 5.5 test
|
||||
#
|
||||
# MDEV-20109: Optimizer ignores distinct key created for materialized
|
||||
# semi-join subquery when searching for best execution plan
|
||||
#
|
||||
create table t1(a int);
|
||||
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
create table t2(a int);
|
||||
insert into t2 select A.a + B.a* 10 + C.a * 100 from t1 A, t1 B, t1 C;
|
||||
create table t3 (a int);
|
||||
create table t4 (a int);
|
||||
insert into t3 select A.a +1000*B.a from t2 A, t1 B;
|
||||
insert into t4 select floor(rand()*1000) from t2 limit 500;
|
||||
# The following must not use this query plan that does a cross join:
|
||||
# | 1 | PRIMARY | <subquery2> | ALL | distinct_key | ... | 500 | |
|
||||
# | 1 | PRIMARY | t3 | ALL | NULL | ... | 10000 | Using where; Using join buffer (flat, BNL join) |
|
||||
#
|
||||
# Instead, it should use eq_ref on the materialized table.
|
||||
explain select * from t3 where a in (select a from t4);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 10000
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 500
|
||||
drop table t1, t2, t3, t4;
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
#
|
||||
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
|
||||
@ -3485,8 +3508,8 @@ EXPLAIN
|
||||
SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a)
|
||||
GROUP BY a HAVING a != 'z';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t range idx_a idx_a 4 NULL 3 Using where; Using index
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 Using temporary; Using filesort
|
||||
1 PRIMARY t ref idx_a idx_a 4 test.t2.b 2 Using index
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 MATERIALIZED t1 ref idx_a idx_a 4 test.t2.b 2 Using index
|
||||
SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a)
|
||||
@ -3499,8 +3522,8 @@ EXPLAIN
|
||||
SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a)
|
||||
GROUP BY a HAVING a != 'z';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t range idx_a idx_a 4 NULL 3 Using where; Using index
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 Using temporary; Using filesort
|
||||
1 PRIMARY t ref idx_a idx_a 4 test.t2.b 2 Using index
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
2 MATERIALIZED t1 ref idx_a idx_a 4 test.t2.b 2 Using index
|
||||
SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a)
|
||||
|
@ -491,15 +491,15 @@ where (c1, c2) in (select b1, b2 from t2i where b2 > '0')) and
|
||||
a1 = c1;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
1 PRIMARY <subquery4> ALL distinct_key NULL NULL NULL 4 100.00 Using where
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 4 99.22 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 16 func,func 1 100.00
|
||||
4 MATERIALIZED t3 ALL NULL NULL NULL NULL 4 99.22 Using where
|
||||
4 MATERIALIZED t2i ref it2i1,it2i2,it2i3 it2i3 18 test.t3.c1,test.t3.c2 1 100.00 Using index
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 99.22 Using where
|
||||
3 DEPENDENT UNION t2 ALL NULL NULL NULL NULL 5 99.22 Using where
|
||||
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` semi join (`test`.`t2i` join `test`.`t3`) join `test`.`t3` where `test`.`t3`.`c1` = `test`.`t1`.`a1` and `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t3`.`c1` = `test`.`t1`.`a1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and `test`.`t3`.`c2` = `test`.`t3`.`c2` and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where `test`.`t1`.`a1` > '0' and <cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1` and <cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2` union /* select#3 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` < '9' and <cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1` and <cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))) and `test`.`t3`.`c2` > '0'
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.`c2` AS `c2` from `test`.`t1` semi join (`test`.`t2i` join `test`.`t3`) join `test`.`t3` where `test`.`t3`.`c1` = `test`.`t1`.`a1` and `test`.`t2i`.`b1` = `test`.`t3`.`c1` and `test`.`t2i`.`b2` = `test`.`t3`.`c2` and <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select `test`.`t1`.`a1`,`test`.`t1`.`a2` from `test`.`t1` where `test`.`t1`.`a1` > '0' and <cache>(`test`.`t1`.`a1`) = `test`.`t1`.`a1` and <cache>(`test`.`t1`.`a2`) = `test`.`t1`.`a2` union /* select#3 */ select `test`.`t2`.`b1`,`test`.`t2`.`b2` from `test`.`t2` where `test`.`t2`.`b1` < '9' and <cache>(`test`.`t1`.`a1`) = `test`.`t2`.`b1` and <cache>(`test`.`t1`.`a2`) = `test`.`t2`.`b2`))) and `test`.`t3`.`c2` > '0'
|
||||
select * from t1, t3
|
||||
where (a1, a2) in (select * from t1 where a1 > '0' UNION select * from t2 where b1 < '9') and
|
||||
(c1, c2) in (select c1, c2 from t3
|
||||
@ -1132,11 +1132,11 @@ insert into t3 values (30);
|
||||
explain extended
|
||||
select a from t1 where a in (select c from t2 where d >= 20);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 6 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 100.00
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t1`.`a` = `test`.`t2`.`c` and `test`.`t2`.`d` >= 20
|
||||
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` semi join (`test`.`t2`) where `test`.`t2`.`d` >= 20
|
||||
select a from t1 where a in (select c from t2 where d >= 20);
|
||||
a
|
||||
2
|
||||
@ -1543,8 +1543,8 @@ set @@optimizer_switch=@optimizer_switch_local_default;
|
||||
SET @@optimizer_switch='semijoin=on,materialization=on';
|
||||
EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 7 func,func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2
|
||||
SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2);
|
||||
COUNT(*)
|
||||
@ -2473,8 +2473,8 @@ INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
|
||||
explain
|
||||
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 hash_ALL NULL #hash#$hj 4 test.t2.i1 9 Using where; Using join buffer (flat, BNLH join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 9
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
|
||||
1
|
||||
@ -2486,8 +2486,8 @@ alter table t1 add key(id);
|
||||
explain
|
||||
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index
|
||||
1 PRIMARY t1 index id id 4 NULL 9 Using index
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
|
||||
1
|
||||
@ -2543,8 +2543,8 @@ INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
|
||||
CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2;
|
||||
explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
|
||||
1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index
|
||||
1 PRIMARY t1 index id id 4 NULL 9 Using index
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
|
||||
1
|
||||
|
@ -743,21 +743,21 @@ a b
|
||||
explain extended select * from t1
|
||||
where a in (values (1));
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
3 MATERIALIZED <derived2> ALL NULL NULL NULL NULL 2 100.00
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1`
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1)) `tvc_0`) where 1
|
||||
explain extended select * from t1
|
||||
where a in (select * from (values (1)) as tvc_0);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1`
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1)) `tvc_0`) where 1
|
||||
# IN-subquery with VALUES structure(s) : UNION with VALUES on the first place
|
||||
select * from t1
|
||||
where a in (values (1) union select 2);
|
||||
@ -978,21 +978,21 @@ a b
|
||||
explain extended select * from t1
|
||||
where a = any (values (1),(2));
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
3 MATERIALIZED <derived2> ALL NULL NULL NULL NULL 2 100.00
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1`
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1
|
||||
explain extended select * from t1
|
||||
where a = any (select * from (values (1),(2)) as tvc_0);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1`
|
||||
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where 1
|
||||
# ANY-subquery with VALUES structure(s) : UNION with VALUES on the first place
|
||||
select * from t1
|
||||
where a = any (values (1) union select 2);
|
||||
|
@ -588,5 +588,53 @@ ts cts uts ucts
|
||||
DROP TABLE t1,t2;
|
||||
SET time_zone=DEFAULT;
|
||||
#
|
||||
# MDEV-19961 MIN(timestamp_column) returns a wrong result in a GROUP BY query
|
||||
#
|
||||
SET time_zone='Europe/Moscow';
|
||||
CREATE OR REPLACE TABLE t1 (i INT, d TIMESTAMP);
|
||||
SET timestamp=1288477526 /* this is summer time */ ;
|
||||
INSERT INTO t1 VALUES (3,NULL);
|
||||
SET timestamp=1288477526+3599 /* this is winter time*/ ;
|
||||
INSERT INTO t1 VALUES (3,NULL);
|
||||
SELECT i, d, UNIX_TIMESTAMP(d) FROM t1 ORDER BY d;
|
||||
i d UNIX_TIMESTAMP(d)
|
||||
3 2010-10-31 02:25:26 1288477526
|
||||
3 2010-10-31 02:25:25 1288481125
|
||||
SELECT i, MIN(d) FROM t1 GROUP BY i;
|
||||
i MIN(d)
|
||||
3 2010-10-31 02:25:26
|
||||
SELECT i, MAX(d) FROM t1 GROUP BY i;
|
||||
i MAX(d)
|
||||
3 2010-10-31 02:25:25
|
||||
DROP TABLE t1;
|
||||
SET timestamp=DEFAULT;
|
||||
SET time_zone=DEFAULT;
|
||||
#
|
||||
# MDEV-20397 Support TIMESTAMP, DATETIME, TIME in ROUND() and TRUNCATE()
|
||||
#
|
||||
SET time_zone='Europe/Moscow';
|
||||
CREATE TABLE t1 (i INT, d TIMESTAMP(6));
|
||||
SET timestamp=1288479599.999999 /* this is the last second in summer time */ ;
|
||||
INSERT INTO t1 VALUES (1,NULL);
|
||||
SET timestamp=1288479600.000000 /* this is the first second in winter time */ ;
|
||||
INSERT INTO t1 VALUES (2,NULL);
|
||||
SELECT i, d, UNIX_TIMESTAMP(d) FROM t1 ORDER BY d;
|
||||
i d UNIX_TIMESTAMP(d)
|
||||
1 2010-10-31 02:59:59.999999 1288479599.999999
|
||||
2 2010-10-31 02:00:00.000000 1288479600.000000
|
||||
CREATE TABLE t2 (i INT, d TIMESTAMP, expected_unix_timestamp INT UNSIGNED);
|
||||
INSERT INTO t2 SELECT i, ROUND(d) AS d, ROUND(UNIX_TIMESTAMP(d)) FROM t1;
|
||||
# UNIX_TIMESTAMP(d) and expected_unix_timestamp should return the same value.
|
||||
# Currently they do not, because ROUND(timestamp) is performed as DATETIME.
|
||||
# We should fix this eventually.
|
||||
SELECT i, d, UNIX_TIMESTAMP(d), expected_unix_timestamp FROM t2 ORDER BY i;
|
||||
i d UNIX_TIMESTAMP(d) expected_unix_timestamp
|
||||
1 2010-10-31 03:00:00 1288483200 1288479600
|
||||
2 2010-10-31 02:00:00 1288476000 1288479600
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
SET timestamp=DEFAULT;
|
||||
SET time_zone=DEFAULT;
|
||||
#
|
||||
# End of 10.4 tests
|
||||
#
|
||||
|
@ -534,6 +534,50 @@ SELECT ts, cts, UNIX_TIMESTAMP(ts) AS uts, UNIX_TIMESTAMP(cts) AS ucts FROM t2;
|
||||
DROP TABLE t1,t2;
|
||||
SET time_zone=DEFAULT;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-19961 MIN(timestamp_column) returns a wrong result in a GROUP BY query
|
||||
--echo #
|
||||
|
||||
SET time_zone='Europe/Moscow';
|
||||
CREATE OR REPLACE TABLE t1 (i INT, d TIMESTAMP);
|
||||
SET timestamp=1288477526 /* this is summer time */ ;
|
||||
INSERT INTO t1 VALUES (3,NULL);
|
||||
SET timestamp=1288477526+3599 /* this is winter time*/ ;
|
||||
INSERT INTO t1 VALUES (3,NULL);
|
||||
SELECT i, d, UNIX_TIMESTAMP(d) FROM t1 ORDER BY d;
|
||||
SELECT i, MIN(d) FROM t1 GROUP BY i;
|
||||
SELECT i, MAX(d) FROM t1 GROUP BY i;
|
||||
DROP TABLE t1;
|
||||
SET timestamp=DEFAULT;
|
||||
SET time_zone=DEFAULT;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-20397 Support TIMESTAMP, DATETIME, TIME in ROUND() and TRUNCATE()
|
||||
--echo #
|
||||
|
||||
SET time_zone='Europe/Moscow';
|
||||
CREATE TABLE t1 (i INT, d TIMESTAMP(6));
|
||||
SET timestamp=1288479599.999999 /* this is the last second in summer time */ ;
|
||||
INSERT INTO t1 VALUES (1,NULL);
|
||||
SET timestamp=1288479600.000000 /* this is the first second in winter time */ ;
|
||||
INSERT INTO t1 VALUES (2,NULL);
|
||||
SELECT i, d, UNIX_TIMESTAMP(d) FROM t1 ORDER BY d;
|
||||
|
||||
CREATE TABLE t2 (i INT, d TIMESTAMP, expected_unix_timestamp INT UNSIGNED);
|
||||
INSERT INTO t2 SELECT i, ROUND(d) AS d, ROUND(UNIX_TIMESTAMP(d)) FROM t1;
|
||||
|
||||
--echo # UNIX_TIMESTAMP(d) and expected_unix_timestamp should return the same value.
|
||||
--echo # Currently they do not, because ROUND(timestamp) is performed as DATETIME.
|
||||
--echo # We should fix this eventually.
|
||||
|
||||
SELECT i, d, UNIX_TIMESTAMP(d), expected_unix_timestamp FROM t2 ORDER BY i;
|
||||
DROP TABLE t2;
|
||||
|
||||
DROP TABLE t1;
|
||||
SET timestamp=DEFAULT;
|
||||
SET time_zone=DEFAULT;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.4 tests
|
||||
--echo #
|
||||
|
@ -890,6 +890,37 @@ DROP TABLE t2;
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-19699 Server crashes in Item_null_result::field_type upon SELECT with ROLLUP on constant table
|
||||
#
|
||||
CREATE TABLE t1 (d DATE) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('1999-11-04');
|
||||
SELECT d FROM t1 GROUP BY d WITH ROLLUP HAVING d > '1990-01-01';
|
||||
d
|
||||
1999-11-04
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-20431 GREATEST(int_col,date_col) returns wrong results in a view
|
||||
#
|
||||
CREATE TABLE t1 (pk INT NOT NULL, d DATE NOT NULL);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
INSERT INTO t1 VALUES (1,'2018-06-22'),(2,'2018-07-11');
|
||||
SELECT GREATEST(pk, d) FROM t1;
|
||||
GREATEST(pk, d)
|
||||
2018-06-22
|
||||
2018-07-11
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '1' for column `test`.`t1`.`pk` at row 1
|
||||
Warning 1292 Incorrect datetime value: '2' for column `test`.`t1`.`pk` at row 2
|
||||
SELECT GREATEST(pk, d) FROM v1;
|
||||
GREATEST(pk, d)
|
||||
2018-06-22
|
||||
2018-07-11
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '1' for column `test`.`t1`.`pk` at row 1
|
||||
Warning 1292 Incorrect datetime value: '2' for column `test`.`t1`.`pk` at row 2
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# End of 10.1 tests
|
||||
#
|
||||
#
|
||||
|
@ -606,6 +606,30 @@ DROP TABLE t2;
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-19699 Server crashes in Item_null_result::field_type upon SELECT with ROLLUP on constant table
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (d DATE) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('1999-11-04');
|
||||
SELECT d FROM t1 GROUP BY d WITH ROLLUP HAVING d > '1990-01-01';
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-20431 GREATEST(int_col,date_col) returns wrong results in a view
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (pk INT NOT NULL, d DATE NOT NULL);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
INSERT INTO t1 VALUES (1,'2018-06-22'),(2,'2018-07-11');
|
||||
SELECT GREATEST(pk, d) FROM t1;
|
||||
SELECT GREATEST(pk, d) FROM v1;
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.1 tests
|
||||
--echo #
|
||||
|
@ -1156,6 +1156,48 @@ ExtractValue('foo','bar') i MIN(d)
|
||||
3 1976-12-14 13:21:07
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-19034 ASAN unknown-crash in get_date_time_separator with PAD_CHAR_TO_FULL_LENGTH
|
||||
#
|
||||
SET SQL_MODE=DEFAULT;
|
||||
CREATE OR REPLACE TABLE t1 (a CHAR(11));
|
||||
CREATE OR REPLACE TABLE t2 (b DATETIME);
|
||||
INSERT INTO t1 VALUES ('2010-02-19') ;
|
||||
SET SQL_MODE= 'PAD_CHAR_TO_FULL_LENGTH';
|
||||
INSERT INTO t2 SELECT * FROM t1;
|
||||
DROP TABLE t1, t2;
|
||||
SET SQL_MODE=DEFAULT;
|
||||
#
|
||||
# MDEV-19699 Server crashes in Item_null_result::field_type upon SELECT with ROLLUP on constant table
|
||||
#
|
||||
CREATE TABLE t1 (d DATETIME) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('1999-11-04');
|
||||
SELECT d FROM t1 GROUP BY d WITH ROLLUP HAVING d > '1990-01-01';
|
||||
d
|
||||
1999-11-04 00:00:00
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-20431 GREATEST(int_col,date_col) returns wrong results in a view
|
||||
#
|
||||
CREATE TABLE t1 (pk INT NOT NULL, d DATETIME NOT NULL);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
INSERT INTO t1 VALUES (1,'2018-06-22 00:00:00'),(2,'2018-07-11 00:00:00');
|
||||
SELECT GREATEST(pk, d) FROM t1;
|
||||
GREATEST(pk, d)
|
||||
2018-06-22 00:00:00
|
||||
2018-07-11 00:00:00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '1' for column `test`.`t1`.`pk` at row 1
|
||||
Warning 1292 Incorrect datetime value: '2' for column `test`.`t1`.`pk` at row 2
|
||||
SELECT GREATEST(pk, d) FROM v1;
|
||||
GREATEST(pk, d)
|
||||
2018-06-22 00:00:00
|
||||
2018-07-11 00:00:00
|
||||
Warnings:
|
||||
Warning 1292 Incorrect datetime value: '1' for column `test`.`t1`.`pk` at row 1
|
||||
Warning 1292 Incorrect datetime value: '2' for column `test`.`t1`.`pk` at row 2
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# End of 10.1 tests
|
||||
#
|
||||
#
|
||||
|
@ -710,6 +710,43 @@ INSERT INTO t1 VALUES (3,NULL),(3,'1976-12-14 13:21:07'),(NULL,'1981-09-24 01:04
|
||||
SELECT ExtractValue('foo','bar'), i, MIN(d) FROM t1 GROUP BY i;
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-19034 ASAN unknown-crash in get_date_time_separator with PAD_CHAR_TO_FULL_LENGTH
|
||||
--echo #
|
||||
|
||||
SET SQL_MODE=DEFAULT;
|
||||
CREATE OR REPLACE TABLE t1 (a CHAR(11));
|
||||
CREATE OR REPLACE TABLE t2 (b DATETIME);
|
||||
INSERT INTO t1 VALUES ('2010-02-19') ;
|
||||
SET SQL_MODE= 'PAD_CHAR_TO_FULL_LENGTH';
|
||||
INSERT INTO t2 SELECT * FROM t1;
|
||||
DROP TABLE t1, t2;
|
||||
SET SQL_MODE=DEFAULT;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-19699 Server crashes in Item_null_result::field_type upon SELECT with ROLLUP on constant table
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (d DATETIME) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('1999-11-04');
|
||||
SELECT d FROM t1 GROUP BY d WITH ROLLUP HAVING d > '1990-01-01';
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-20431 GREATEST(int_col,date_col) returns wrong results in a view
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (pk INT NOT NULL, d DATETIME NOT NULL);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
INSERT INTO t1 VALUES (1,'2018-06-22 00:00:00'),(2,'2018-07-11 00:00:00');
|
||||
SELECT GREATEST(pk, d) FROM t1;
|
||||
SELECT GREATEST(pk, d) FROM v1;
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.1 tests
|
||||
--echo #
|
||||
|
@ -17,8 +17,8 @@ a
|
||||
2010-12-11 01:02:03.456
|
||||
2010-12-11 03:04:05.789
|
||||
2010-12-11 15:47:11.123
|
||||
select truncate(a, 6) from t1;
|
||||
truncate(a, 6)
|
||||
select cast(a AS double(30,6)) from t1;
|
||||
cast(a AS double(30,6))
|
||||
0.000000
|
||||
20101211002003.120000
|
||||
20101211010203.457031
|
||||
@ -352,3 +352,542 @@ NULL
|
||||
978307200.0000
|
||||
DROP TABLE t1;
|
||||
SET @@time_zone=DEFAULT;
|
||||
#
|
||||
# Start of 10.4 tests
|
||||
#
|
||||
#
|
||||
# MDEV-20397 Support TIMESTAMP, DATETIME, TIME in ROUND() and TRUNCATE()
|
||||
#
|
||||
CREATE TABLE t1 (a1 DATETIME(6), a2 DATETIME(6) NOT NULL);
|
||||
CREATE TABLE t2 AS SELECT
|
||||
ROUND(a1) AS r1,
|
||||
ROUND(a2) AS r2,
|
||||
TRUNCATE(a1,0) AS t1,
|
||||
TRUNCATE(a2,0) AS t2
|
||||
FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`r1` datetime DEFAULT NULL,
|
||||
`r2` datetime DEFAULT NULL,
|
||||
`t1` datetime DEFAULT NULL,
|
||||
`t2` datetime NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a DATETIME(6));
|
||||
INSERT INTO t1 VALUES
|
||||
('0000-00-00 00:00:00.999999'),
|
||||
('0000-00-00 23:59:59.999999'),
|
||||
('0000-00-01 00:00:00.999999'),
|
||||
('0000-00-01 23:59:59.999999'),
|
||||
('0000-00-31 23:59:59.999999'),
|
||||
('0000-01-01 00:00:00.999999'),
|
||||
('0000-01-01 23:59:59.999999'),
|
||||
('0000-01-31 23:59:59.999999'),
|
||||
('0000-02-28 23:59:59.999999'),
|
||||
('0000-12-31 23:59:59.999999'),
|
||||
('0001-01-01 00:00:00.999999'),
|
||||
('0001-02-28 23:59:59.999999'),
|
||||
('0001-12-31 23:59:59.999999'),
|
||||
('0004-02-28 23:59:59.999999'),
|
||||
('0004-02-29 23:59:59.999999'),
|
||||
('2000-02-29 23:59:59.999999'),
|
||||
('2000-12-31 23:59:59.999999'),
|
||||
('9999-12-31 23:59:59.999999');
|
||||
SELECT a, TRUNCATE(a,0) FROM t1;
|
||||
a TRUNCATE(a,0)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:00
|
||||
0000-00-00 23:59:59.999999 0000-00-00 23:59:59
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:00
|
||||
0000-00-01 23:59:59.999999 0000-00-01 23:59:59
|
||||
0000-00-31 23:59:59.999999 0000-00-31 23:59:59
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:00
|
||||
0000-01-01 23:59:59.999999 0000-01-01 23:59:59
|
||||
0000-01-31 23:59:59.999999 0000-01-31 23:59:59
|
||||
0000-02-28 23:59:59.999999 0000-02-28 23:59:59
|
||||
0000-12-31 23:59:59.999999 0000-12-31 23:59:59
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:00
|
||||
0001-02-28 23:59:59.999999 0001-02-28 23:59:59
|
||||
0001-12-31 23:59:59.999999 0001-12-31 23:59:59
|
||||
0004-02-28 23:59:59.999999 0004-02-28 23:59:59
|
||||
0004-02-29 23:59:59.999999 0004-02-29 23:59:59
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59
|
||||
SELECT a, TRUNCATE(a,1) FROM t1;
|
||||
a TRUNCATE(a,1)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:00.9
|
||||
0000-00-00 23:59:59.999999 0000-00-00 23:59:59.9
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:00.9
|
||||
0000-00-01 23:59:59.999999 0000-00-01 23:59:59.9
|
||||
0000-00-31 23:59:59.999999 0000-00-31 23:59:59.9
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:00.9
|
||||
0000-01-01 23:59:59.999999 0000-01-01 23:59:59.9
|
||||
0000-01-31 23:59:59.999999 0000-01-31 23:59:59.9
|
||||
0000-02-28 23:59:59.999999 0000-02-28 23:59:59.9
|
||||
0000-12-31 23:59:59.999999 0000-12-31 23:59:59.9
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:00.9
|
||||
0001-02-28 23:59:59.999999 0001-02-28 23:59:59.9
|
||||
0001-12-31 23:59:59.999999 0001-12-31 23:59:59.9
|
||||
0004-02-28 23:59:59.999999 0004-02-28 23:59:59.9
|
||||
0004-02-29 23:59:59.999999 0004-02-29 23:59:59.9
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.9
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.9
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59.9
|
||||
SELECT a, TRUNCATE(a,2) FROM t1;
|
||||
a TRUNCATE(a,2)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:00.99
|
||||
0000-00-00 23:59:59.999999 0000-00-00 23:59:59.99
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:00.99
|
||||
0000-00-01 23:59:59.999999 0000-00-01 23:59:59.99
|
||||
0000-00-31 23:59:59.999999 0000-00-31 23:59:59.99
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:00.99
|
||||
0000-01-01 23:59:59.999999 0000-01-01 23:59:59.99
|
||||
0000-01-31 23:59:59.999999 0000-01-31 23:59:59.99
|
||||
0000-02-28 23:59:59.999999 0000-02-28 23:59:59.99
|
||||
0000-12-31 23:59:59.999999 0000-12-31 23:59:59.99
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:00.99
|
||||
0001-02-28 23:59:59.999999 0001-02-28 23:59:59.99
|
||||
0001-12-31 23:59:59.999999 0001-12-31 23:59:59.99
|
||||
0004-02-28 23:59:59.999999 0004-02-28 23:59:59.99
|
||||
0004-02-29 23:59:59.999999 0004-02-29 23:59:59.99
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.99
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.99
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59.99
|
||||
SELECT a, TRUNCATE(a,3) FROM t1;
|
||||
a TRUNCATE(a,3)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:00.999
|
||||
0000-00-00 23:59:59.999999 0000-00-00 23:59:59.999
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:00.999
|
||||
0000-00-01 23:59:59.999999 0000-00-01 23:59:59.999
|
||||
0000-00-31 23:59:59.999999 0000-00-31 23:59:59.999
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:00.999
|
||||
0000-01-01 23:59:59.999999 0000-01-01 23:59:59.999
|
||||
0000-01-31 23:59:59.999999 0000-01-31 23:59:59.999
|
||||
0000-02-28 23:59:59.999999 0000-02-28 23:59:59.999
|
||||
0000-12-31 23:59:59.999999 0000-12-31 23:59:59.999
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:00.999
|
||||
0001-02-28 23:59:59.999999 0001-02-28 23:59:59.999
|
||||
0001-12-31 23:59:59.999999 0001-12-31 23:59:59.999
|
||||
0004-02-28 23:59:59.999999 0004-02-28 23:59:59.999
|
||||
0004-02-29 23:59:59.999999 0004-02-29 23:59:59.999
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.999
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.999
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59.999
|
||||
SELECT a, TRUNCATE(a,4) FROM t1;
|
||||
a TRUNCATE(a,4)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:00.9999
|
||||
0000-00-00 23:59:59.999999 0000-00-00 23:59:59.9999
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:00.9999
|
||||
0000-00-01 23:59:59.999999 0000-00-01 23:59:59.9999
|
||||
0000-00-31 23:59:59.999999 0000-00-31 23:59:59.9999
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:00.9999
|
||||
0000-01-01 23:59:59.999999 0000-01-01 23:59:59.9999
|
||||
0000-01-31 23:59:59.999999 0000-01-31 23:59:59.9999
|
||||
0000-02-28 23:59:59.999999 0000-02-28 23:59:59.9999
|
||||
0000-12-31 23:59:59.999999 0000-12-31 23:59:59.9999
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:00.9999
|
||||
0001-02-28 23:59:59.999999 0001-02-28 23:59:59.9999
|
||||
0001-12-31 23:59:59.999999 0001-12-31 23:59:59.9999
|
||||
0004-02-28 23:59:59.999999 0004-02-28 23:59:59.9999
|
||||
0004-02-29 23:59:59.999999 0004-02-29 23:59:59.9999
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.9999
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.9999
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59.9999
|
||||
SELECT a, TRUNCATE(a,5) FROM t1;
|
||||
a TRUNCATE(a,5)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:00.99999
|
||||
0000-00-00 23:59:59.999999 0000-00-00 23:59:59.99999
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:00.99999
|
||||
0000-00-01 23:59:59.999999 0000-00-01 23:59:59.99999
|
||||
0000-00-31 23:59:59.999999 0000-00-31 23:59:59.99999
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:00.99999
|
||||
0000-01-01 23:59:59.999999 0000-01-01 23:59:59.99999
|
||||
0000-01-31 23:59:59.999999 0000-01-31 23:59:59.99999
|
||||
0000-02-28 23:59:59.999999 0000-02-28 23:59:59.99999
|
||||
0000-12-31 23:59:59.999999 0000-12-31 23:59:59.99999
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:00.99999
|
||||
0001-02-28 23:59:59.999999 0001-02-28 23:59:59.99999
|
||||
0001-12-31 23:59:59.999999 0001-12-31 23:59:59.99999
|
||||
0004-02-28 23:59:59.999999 0004-02-28 23:59:59.99999
|
||||
0004-02-29 23:59:59.999999 0004-02-29 23:59:59.99999
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.99999
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.99999
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59.99999
|
||||
SELECT a, TRUNCATE(a,6) FROM t1;
|
||||
a TRUNCATE(a,6)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:00.999999
|
||||
0000-00-00 23:59:59.999999 0000-00-00 23:59:59.999999
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:00.999999
|
||||
0000-00-01 23:59:59.999999 0000-00-01 23:59:59.999999
|
||||
0000-00-31 23:59:59.999999 0000-00-31 23:59:59.999999
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:00.999999
|
||||
0000-01-01 23:59:59.999999 0000-01-01 23:59:59.999999
|
||||
0000-01-31 23:59:59.999999 0000-01-31 23:59:59.999999
|
||||
0000-02-28 23:59:59.999999 0000-02-28 23:59:59.999999
|
||||
0000-12-31 23:59:59.999999 0000-12-31 23:59:59.999999
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:00.999999
|
||||
0001-02-28 23:59:59.999999 0001-02-28 23:59:59.999999
|
||||
0001-12-31 23:59:59.999999 0001-12-31 23:59:59.999999
|
||||
0004-02-28 23:59:59.999999 0004-02-28 23:59:59.999999
|
||||
0004-02-29 23:59:59.999999 0004-02-29 23:59:59.999999
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.999999
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.999999
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59.999999
|
||||
SELECT a, TRUNCATE(a,7) FROM t1;
|
||||
a TRUNCATE(a,7)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:00.999999
|
||||
0000-00-00 23:59:59.999999 0000-00-00 23:59:59.999999
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:00.999999
|
||||
0000-00-01 23:59:59.999999 0000-00-01 23:59:59.999999
|
||||
0000-00-31 23:59:59.999999 0000-00-31 23:59:59.999999
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:00.999999
|
||||
0000-01-01 23:59:59.999999 0000-01-01 23:59:59.999999
|
||||
0000-01-31 23:59:59.999999 0000-01-31 23:59:59.999999
|
||||
0000-02-28 23:59:59.999999 0000-02-28 23:59:59.999999
|
||||
0000-12-31 23:59:59.999999 0000-12-31 23:59:59.999999
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:00.999999
|
||||
0001-02-28 23:59:59.999999 0001-02-28 23:59:59.999999
|
||||
0001-12-31 23:59:59.999999 0001-12-31 23:59:59.999999
|
||||
0004-02-28 23:59:59.999999 0004-02-28 23:59:59.999999
|
||||
0004-02-29 23:59:59.999999 0004-02-29 23:59:59.999999
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.999999
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.999999
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59.999999
|
||||
SELECT a, TRUNCATE(a,-1) FROM t1;
|
||||
a TRUNCATE(a,-1)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:00
|
||||
0000-00-00 23:59:59.999999 0000-00-00 23:59:59
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:00
|
||||
0000-00-01 23:59:59.999999 0000-00-01 23:59:59
|
||||
0000-00-31 23:59:59.999999 0000-00-31 23:59:59
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:00
|
||||
0000-01-01 23:59:59.999999 0000-01-01 23:59:59
|
||||
0000-01-31 23:59:59.999999 0000-01-31 23:59:59
|
||||
0000-02-28 23:59:59.999999 0000-02-28 23:59:59
|
||||
0000-12-31 23:59:59.999999 0000-12-31 23:59:59
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:00
|
||||
0001-02-28 23:59:59.999999 0001-02-28 23:59:59
|
||||
0001-12-31 23:59:59.999999 0001-12-31 23:59:59
|
||||
0004-02-28 23:59:59.999999 0004-02-28 23:59:59
|
||||
0004-02-29 23:59:59.999999 0004-02-29 23:59:59
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59
|
||||
SELECT a, TRUNCATE(a,-6) FROM t1;
|
||||
a TRUNCATE(a,-6)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:00
|
||||
0000-00-00 23:59:59.999999 0000-00-00 23:59:59
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:00
|
||||
0000-00-01 23:59:59.999999 0000-00-01 23:59:59
|
||||
0000-00-31 23:59:59.999999 0000-00-31 23:59:59
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:00
|
||||
0000-01-01 23:59:59.999999 0000-01-01 23:59:59
|
||||
0000-01-31 23:59:59.999999 0000-01-31 23:59:59
|
||||
0000-02-28 23:59:59.999999 0000-02-28 23:59:59
|
||||
0000-12-31 23:59:59.999999 0000-12-31 23:59:59
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:00
|
||||
0001-02-28 23:59:59.999999 0001-02-28 23:59:59
|
||||
0001-12-31 23:59:59.999999 0001-12-31 23:59:59
|
||||
0004-02-28 23:59:59.999999 0004-02-28 23:59:59
|
||||
0004-02-29 23:59:59.999999 0004-02-29 23:59:59
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59
|
||||
SELECT a, ROUND(a) FROM t1;
|
||||
a ROUND(a)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:01
|
||||
0000-00-00 23:59:59.999999 NULL
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:01
|
||||
0000-00-01 23:59:59.999999 NULL
|
||||
0000-00-31 23:59:59.999999 NULL
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:01
|
||||
0000-01-01 23:59:59.999999 NULL
|
||||
0000-01-31 23:59:59.999999 NULL
|
||||
0000-02-28 23:59:59.999999 NULL
|
||||
0000-12-31 23:59:59.999999 NULL
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:01
|
||||
0001-02-28 23:59:59.999999 0001-03-01 00:00:00
|
||||
0001-12-31 23:59:59.999999 0002-01-01 00:00:00
|
||||
0004-02-28 23:59:59.999999 0004-02-29 00:00:00
|
||||
0004-02-29 23:59:59.999999 0004-03-01 00:00:00
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59
|
||||
Warnings:
|
||||
Warning 1411 Incorrect date value: '0000-00-00' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-02-28' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-12-31' for function round(datetime)
|
||||
SELECT a, ROUND(a,0) FROM t1;
|
||||
a ROUND(a,0)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:01
|
||||
0000-00-00 23:59:59.999999 NULL
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:01
|
||||
0000-00-01 23:59:59.999999 NULL
|
||||
0000-00-31 23:59:59.999999 NULL
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:01
|
||||
0000-01-01 23:59:59.999999 NULL
|
||||
0000-01-31 23:59:59.999999 NULL
|
||||
0000-02-28 23:59:59.999999 NULL
|
||||
0000-12-31 23:59:59.999999 NULL
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:01
|
||||
0001-02-28 23:59:59.999999 0001-03-01 00:00:00
|
||||
0001-12-31 23:59:59.999999 0002-01-01 00:00:00
|
||||
0004-02-28 23:59:59.999999 0004-02-29 00:00:00
|
||||
0004-02-29 23:59:59.999999 0004-03-01 00:00:00
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59
|
||||
Warnings:
|
||||
Warning 1411 Incorrect date value: '0000-00-00' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-02-28' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-12-31' for function round(datetime)
|
||||
SELECT a, ROUND(a,1) FROM t1;
|
||||
a ROUND(a,1)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:01.0
|
||||
0000-00-00 23:59:59.999999 NULL
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:01.0
|
||||
0000-00-01 23:59:59.999999 NULL
|
||||
0000-00-31 23:59:59.999999 NULL
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:01.0
|
||||
0000-01-01 23:59:59.999999 NULL
|
||||
0000-01-31 23:59:59.999999 NULL
|
||||
0000-02-28 23:59:59.999999 NULL
|
||||
0000-12-31 23:59:59.999999 NULL
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:01.0
|
||||
0001-02-28 23:59:59.999999 0001-03-01 00:00:00.0
|
||||
0001-12-31 23:59:59.999999 0002-01-01 00:00:00.0
|
||||
0004-02-28 23:59:59.999999 0004-02-29 00:00:00.0
|
||||
0004-02-29 23:59:59.999999 0004-03-01 00:00:00.0
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00.0
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00.0
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59.9
|
||||
Warnings:
|
||||
Warning 1411 Incorrect date value: '0000-00-00' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-02-28' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-12-31' for function round(datetime)
|
||||
SELECT a, ROUND(a,2) FROM t1;
|
||||
a ROUND(a,2)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:01.00
|
||||
0000-00-00 23:59:59.999999 NULL
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:01.00
|
||||
0000-00-01 23:59:59.999999 NULL
|
||||
0000-00-31 23:59:59.999999 NULL
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:01.00
|
||||
0000-01-01 23:59:59.999999 NULL
|
||||
0000-01-31 23:59:59.999999 NULL
|
||||
0000-02-28 23:59:59.999999 NULL
|
||||
0000-12-31 23:59:59.999999 NULL
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:01.00
|
||||
0001-02-28 23:59:59.999999 0001-03-01 00:00:00.00
|
||||
0001-12-31 23:59:59.999999 0002-01-01 00:00:00.00
|
||||
0004-02-28 23:59:59.999999 0004-02-29 00:00:00.00
|
||||
0004-02-29 23:59:59.999999 0004-03-01 00:00:00.00
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00.00
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00.00
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59.99
|
||||
Warnings:
|
||||
Warning 1411 Incorrect date value: '0000-00-00' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-02-28' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-12-31' for function round(datetime)
|
||||
SELECT a, ROUND(a,3) FROM t1;
|
||||
a ROUND(a,3)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:01.000
|
||||
0000-00-00 23:59:59.999999 NULL
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:01.000
|
||||
0000-00-01 23:59:59.999999 NULL
|
||||
0000-00-31 23:59:59.999999 NULL
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:01.000
|
||||
0000-01-01 23:59:59.999999 NULL
|
||||
0000-01-31 23:59:59.999999 NULL
|
||||
0000-02-28 23:59:59.999999 NULL
|
||||
0000-12-31 23:59:59.999999 NULL
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:01.000
|
||||
0001-02-28 23:59:59.999999 0001-03-01 00:00:00.000
|
||||
0001-12-31 23:59:59.999999 0002-01-01 00:00:00.000
|
||||
0004-02-28 23:59:59.999999 0004-02-29 00:00:00.000
|
||||
0004-02-29 23:59:59.999999 0004-03-01 00:00:00.000
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00.000
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00.000
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59.999
|
||||
Warnings:
|
||||
Warning 1411 Incorrect date value: '0000-00-00' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-02-28' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-12-31' for function round(datetime)
|
||||
SELECT a, ROUND(a,4) FROM t1;
|
||||
a ROUND(a,4)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:01.0000
|
||||
0000-00-00 23:59:59.999999 NULL
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:01.0000
|
||||
0000-00-01 23:59:59.999999 NULL
|
||||
0000-00-31 23:59:59.999999 NULL
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:01.0000
|
||||
0000-01-01 23:59:59.999999 NULL
|
||||
0000-01-31 23:59:59.999999 NULL
|
||||
0000-02-28 23:59:59.999999 NULL
|
||||
0000-12-31 23:59:59.999999 NULL
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:01.0000
|
||||
0001-02-28 23:59:59.999999 0001-03-01 00:00:00.0000
|
||||
0001-12-31 23:59:59.999999 0002-01-01 00:00:00.0000
|
||||
0004-02-28 23:59:59.999999 0004-02-29 00:00:00.0000
|
||||
0004-02-29 23:59:59.999999 0004-03-01 00:00:00.0000
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00.0000
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00.0000
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59.9999
|
||||
Warnings:
|
||||
Warning 1411 Incorrect date value: '0000-00-00' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-02-28' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-12-31' for function round(datetime)
|
||||
SELECT a, ROUND(a,5) FROM t1;
|
||||
a ROUND(a,5)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:01.00000
|
||||
0000-00-00 23:59:59.999999 NULL
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:01.00000
|
||||
0000-00-01 23:59:59.999999 NULL
|
||||
0000-00-31 23:59:59.999999 NULL
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:01.00000
|
||||
0000-01-01 23:59:59.999999 NULL
|
||||
0000-01-31 23:59:59.999999 NULL
|
||||
0000-02-28 23:59:59.999999 NULL
|
||||
0000-12-31 23:59:59.999999 NULL
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:01.00000
|
||||
0001-02-28 23:59:59.999999 0001-03-01 00:00:00.00000
|
||||
0001-12-31 23:59:59.999999 0002-01-01 00:00:00.00000
|
||||
0004-02-28 23:59:59.999999 0004-02-29 00:00:00.00000
|
||||
0004-02-29 23:59:59.999999 0004-03-01 00:00:00.00000
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00.00000
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00.00000
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59.99999
|
||||
Warnings:
|
||||
Warning 1411 Incorrect date value: '0000-00-00' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-02-28' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-12-31' for function round(datetime)
|
||||
SELECT a, ROUND(a,6) FROM t1;
|
||||
a ROUND(a,6)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:00.999999
|
||||
0000-00-00 23:59:59.999999 0000-00-00 23:59:59.999999
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:00.999999
|
||||
0000-00-01 23:59:59.999999 0000-00-01 23:59:59.999999
|
||||
0000-00-31 23:59:59.999999 0000-00-31 23:59:59.999999
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:00.999999
|
||||
0000-01-01 23:59:59.999999 0000-01-01 23:59:59.999999
|
||||
0000-01-31 23:59:59.999999 0000-01-31 23:59:59.999999
|
||||
0000-02-28 23:59:59.999999 0000-02-28 23:59:59.999999
|
||||
0000-12-31 23:59:59.999999 0000-12-31 23:59:59.999999
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:00.999999
|
||||
0001-02-28 23:59:59.999999 0001-02-28 23:59:59.999999
|
||||
0001-12-31 23:59:59.999999 0001-12-31 23:59:59.999999
|
||||
0004-02-28 23:59:59.999999 0004-02-28 23:59:59.999999
|
||||
0004-02-29 23:59:59.999999 0004-02-29 23:59:59.999999
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.999999
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.999999
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59.999999
|
||||
SELECT a, ROUND(a,7) FROM t1;
|
||||
a ROUND(a,7)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:00.999999
|
||||
0000-00-00 23:59:59.999999 0000-00-00 23:59:59.999999
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:00.999999
|
||||
0000-00-01 23:59:59.999999 0000-00-01 23:59:59.999999
|
||||
0000-00-31 23:59:59.999999 0000-00-31 23:59:59.999999
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:00.999999
|
||||
0000-01-01 23:59:59.999999 0000-01-01 23:59:59.999999
|
||||
0000-01-31 23:59:59.999999 0000-01-31 23:59:59.999999
|
||||
0000-02-28 23:59:59.999999 0000-02-28 23:59:59.999999
|
||||
0000-12-31 23:59:59.999999 0000-12-31 23:59:59.999999
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:00.999999
|
||||
0001-02-28 23:59:59.999999 0001-02-28 23:59:59.999999
|
||||
0001-12-31 23:59:59.999999 0001-12-31 23:59:59.999999
|
||||
0004-02-28 23:59:59.999999 0004-02-28 23:59:59.999999
|
||||
0004-02-29 23:59:59.999999 0004-02-29 23:59:59.999999
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.999999
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.999999
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59.999999
|
||||
SELECT a, ROUND(a,-1) FROM t1;
|
||||
a ROUND(a,-1)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:01
|
||||
0000-00-00 23:59:59.999999 NULL
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:01
|
||||
0000-00-01 23:59:59.999999 NULL
|
||||
0000-00-31 23:59:59.999999 NULL
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:01
|
||||
0000-01-01 23:59:59.999999 NULL
|
||||
0000-01-31 23:59:59.999999 NULL
|
||||
0000-02-28 23:59:59.999999 NULL
|
||||
0000-12-31 23:59:59.999999 NULL
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:01
|
||||
0001-02-28 23:59:59.999999 0001-03-01 00:00:00
|
||||
0001-12-31 23:59:59.999999 0002-01-01 00:00:00
|
||||
0004-02-28 23:59:59.999999 0004-02-29 00:00:00
|
||||
0004-02-29 23:59:59.999999 0004-03-01 00:00:00
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59
|
||||
Warnings:
|
||||
Warning 1411 Incorrect date value: '0000-00-00' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-02-28' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-12-31' for function round(datetime)
|
||||
SELECT a, ROUND(a,-6) FROM t1;
|
||||
a ROUND(a,-6)
|
||||
0000-00-00 00:00:00.999999 0000-00-00 00:00:01
|
||||
0000-00-00 23:59:59.999999 NULL
|
||||
0000-00-01 00:00:00.999999 0000-00-01 00:00:01
|
||||
0000-00-01 23:59:59.999999 NULL
|
||||
0000-00-31 23:59:59.999999 NULL
|
||||
0000-01-01 00:00:00.999999 0000-01-01 00:00:01
|
||||
0000-01-01 23:59:59.999999 NULL
|
||||
0000-01-31 23:59:59.999999 NULL
|
||||
0000-02-28 23:59:59.999999 NULL
|
||||
0000-12-31 23:59:59.999999 NULL
|
||||
0001-01-01 00:00:00.999999 0001-01-01 00:00:01
|
||||
0001-02-28 23:59:59.999999 0001-03-01 00:00:00
|
||||
0001-12-31 23:59:59.999999 0002-01-01 00:00:00
|
||||
0004-02-28 23:59:59.999999 0004-02-29 00:00:00
|
||||
0004-02-29 23:59:59.999999 0004-03-01 00:00:00
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00
|
||||
9999-12-31 23:59:59.999999 9999-12-31 23:59:59
|
||||
Warnings:
|
||||
Warning 1411 Incorrect date value: '0000-00-00' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-00-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-01' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-01-31' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-02-28' for function round(datetime)
|
||||
Warning 1411 Incorrect date value: '0000-12-31' for function round(datetime)
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# End of 10.4 tests
|
||||
#
|
||||
|
@ -79,3 +79,73 @@ INSERT INTO t1 VALUES ('2001-01-01 00:00:00'),('2000-00-00 00:00:00');
|
||||
SELECT UNIX_TIMESTAMP(a) FROM t1 ORDER BY 1;
|
||||
DROP TABLE t1;
|
||||
SET @@time_zone=DEFAULT;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Start of 10.4 tests
|
||||
--echo #
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-20397 Support TIMESTAMP, DATETIME, TIME in ROUND() and TRUNCATE()
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a1 DATETIME(6), a2 DATETIME(6) NOT NULL);
|
||||
CREATE TABLE t2 AS SELECT
|
||||
ROUND(a1) AS r1,
|
||||
ROUND(a2) AS r2,
|
||||
TRUNCATE(a1,0) AS t1,
|
||||
TRUNCATE(a2,0) AS t2
|
||||
FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
CREATE TABLE t1 (a DATETIME(6));
|
||||
INSERT INTO t1 VALUES
|
||||
('0000-00-00 00:00:00.999999'),
|
||||
('0000-00-00 23:59:59.999999'),
|
||||
('0000-00-01 00:00:00.999999'),
|
||||
('0000-00-01 23:59:59.999999'),
|
||||
('0000-00-31 23:59:59.999999'),
|
||||
('0000-01-01 00:00:00.999999'),
|
||||
('0000-01-01 23:59:59.999999'),
|
||||
('0000-01-31 23:59:59.999999'),
|
||||
('0000-02-28 23:59:59.999999'),
|
||||
('0000-12-31 23:59:59.999999'),
|
||||
('0001-01-01 00:00:00.999999'),
|
||||
('0001-02-28 23:59:59.999999'),
|
||||
('0001-12-31 23:59:59.999999'),
|
||||
('0004-02-28 23:59:59.999999'),
|
||||
('0004-02-29 23:59:59.999999'),
|
||||
('2000-02-29 23:59:59.999999'),
|
||||
('2000-12-31 23:59:59.999999'),
|
||||
('9999-12-31 23:59:59.999999');
|
||||
SELECT a, TRUNCATE(a,0) FROM t1;
|
||||
SELECT a, TRUNCATE(a,1) FROM t1;
|
||||
SELECT a, TRUNCATE(a,2) FROM t1;
|
||||
SELECT a, TRUNCATE(a,3) FROM t1;
|
||||
SELECT a, TRUNCATE(a,4) FROM t1;
|
||||
SELECT a, TRUNCATE(a,5) FROM t1;
|
||||
SELECT a, TRUNCATE(a,6) FROM t1;
|
||||
SELECT a, TRUNCATE(a,7) FROM t1;
|
||||
SELECT a, TRUNCATE(a,-1) FROM t1;
|
||||
SELECT a, TRUNCATE(a,-6) FROM t1;
|
||||
|
||||
SELECT a, ROUND(a) FROM t1;
|
||||
SELECT a, ROUND(a,0) FROM t1;
|
||||
SELECT a, ROUND(a,1) FROM t1;
|
||||
SELECT a, ROUND(a,2) FROM t1;
|
||||
SELECT a, ROUND(a,3) FROM t1;
|
||||
SELECT a, ROUND(a,4) FROM t1;
|
||||
SELECT a, ROUND(a,5) FROM t1;
|
||||
SELECT a, ROUND(a,6) FROM t1;
|
||||
SELECT a, ROUND(a,7) FROM t1;
|
||||
SELECT a, ROUND(a,-1) FROM t1;
|
||||
SELECT a, ROUND(a,-6) FROM t1;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.4 tests
|
||||
--echo #
|
||||
|
@ -1,4 +1,28 @@
|
||||
#
|
||||
# Start of 5.5 tests
|
||||
#
|
||||
#
|
||||
# MDEV-15955 Assertion `field_types == 0 || field_types[field_pos] == MYSQL_TYPE_LONGLONG' failed in Protocol_text::store_longlong
|
||||
#
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
SELECT @a := 1 FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
|
||||
@a := 1
|
||||
1
|
||||
SELECT COALESCE(1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
|
||||
COALESCE(1)
|
||||
1
|
||||
SELECT COALESCE(@a:=1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
|
||||
COALESCE(@a:=1)
|
||||
1
|
||||
SELECT COALESCE(@a) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
|
||||
COALESCE(@a)
|
||||
1
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# End of 5.5 tests
|
||||
#
|
||||
#
|
||||
# Start of 10.1 tests
|
||||
#
|
||||
#
|
||||
|
@ -1,3 +1,24 @@
|
||||
--echo #
|
||||
--echo # Start of 5.5 tests
|
||||
--echo #
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-15955 Assertion `field_types == 0 || field_types[field_pos] == MYSQL_TYPE_LONGLONG' failed in Protocol_text::store_longlong
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a INT);
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
SELECT @a := 1 FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
|
||||
SELECT COALESCE(1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
|
||||
SELECT COALESCE(@a:=1) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
|
||||
SELECT COALESCE(@a) FROM t1 ORDER BY STRCMP(STDDEV_SAMP(a), 'bar');
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # End of 5.5 tests
|
||||
--echo #
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Start of 10.1 tests
|
||||
--echo #
|
||||
|
@ -25,8 +25,8 @@ a
|
||||
03:04:05.789
|
||||
15:47:11.123
|
||||
838:59:59.999
|
||||
select truncate(a, 6) from t1;
|
||||
truncate(a, 6)
|
||||
select cast(a AS double(30,6)) from t1;
|
||||
cast(a AS double(30,6))
|
||||
2003.123000
|
||||
10203.456000
|
||||
30405.789062
|
||||
@ -359,3 +359,314 @@ drop table t1;
|
||||
select cast(1e-6 as time(6));
|
||||
cast(1e-6 as time(6))
|
||||
00:00:00.000001
|
||||
#
|
||||
# Start of 10.4 tests
|
||||
#
|
||||
#
|
||||
# MDEV-20397 Support TIMESTAMP, DATETIME, TIME in ROUND() and TRUNCATE()
|
||||
#
|
||||
CREATE TABLE t1 (a1 TIME(6), a2 TIME(6) NOT NULL);
|
||||
CREATE TABLE t2 AS SELECT
|
||||
ROUND(a1) AS r1,
|
||||
ROUND(a2) AS r2,
|
||||
TRUNCATE(a1,0) AS t1,
|
||||
TRUNCATE(a2,0) AS t2
|
||||
FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`r1` time DEFAULT NULL,
|
||||
`r2` time NOT NULL,
|
||||
`t1` time DEFAULT NULL,
|
||||
`t2` time NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a TIME(6));
|
||||
INSERT INTO t1 VALUES
|
||||
('-838:59:59.999999'),
|
||||
('-837:59:59.999999'),
|
||||
('-23:59:59.999999'),
|
||||
('-00:59:59.999999'),
|
||||
('-00:00:59.999999'),
|
||||
('00:00:00.999999'),
|
||||
('00:00:59.999999'),
|
||||
('00:59:59.999999'),
|
||||
('23:59:59.999999'),
|
||||
('837:59:59.999999'),
|
||||
('838:59:59.999999');
|
||||
SELECT a, TRUNCATE(a,0) FROM t1;
|
||||
a TRUNCATE(a,0)
|
||||
-838:59:59.999999 -838:59:59
|
||||
-837:59:59.999999 -837:59:59
|
||||
-23:59:59.999999 -23:59:59
|
||||
-00:59:59.999999 -00:59:59
|
||||
-00:00:59.999999 -00:00:59
|
||||
00:00:00.999999 00:00:00
|
||||
00:00:59.999999 00:00:59
|
||||
00:59:59.999999 00:59:59
|
||||
23:59:59.999999 23:59:59
|
||||
837:59:59.999999 837:59:59
|
||||
838:59:59.999999 838:59:59
|
||||
SELECT a, TRUNCATE(a,1) FROM t1;
|
||||
a TRUNCATE(a,1)
|
||||
-838:59:59.999999 -838:59:59.9
|
||||
-837:59:59.999999 -837:59:59.9
|
||||
-23:59:59.999999 -23:59:59.9
|
||||
-00:59:59.999999 -00:59:59.9
|
||||
-00:00:59.999999 -00:00:59.9
|
||||
00:00:00.999999 00:00:00.9
|
||||
00:00:59.999999 00:00:59.9
|
||||
00:59:59.999999 00:59:59.9
|
||||
23:59:59.999999 23:59:59.9
|
||||
837:59:59.999999 837:59:59.9
|
||||
838:59:59.999999 838:59:59.9
|
||||
SELECT a, TRUNCATE(a,2) FROM t1;
|
||||
a TRUNCATE(a,2)
|
||||
-838:59:59.999999 -838:59:59.99
|
||||
-837:59:59.999999 -837:59:59.99
|
||||
-23:59:59.999999 -23:59:59.99
|
||||
-00:59:59.999999 -00:59:59.99
|
||||
-00:00:59.999999 -00:00:59.99
|
||||
00:00:00.999999 00:00:00.99
|
||||
00:00:59.999999 00:00:59.99
|
||||
00:59:59.999999 00:59:59.99
|
||||
23:59:59.999999 23:59:59.99
|
||||
837:59:59.999999 837:59:59.99
|
||||
838:59:59.999999 838:59:59.99
|
||||
SELECT a, TRUNCATE(a,3) FROM t1;
|
||||
a TRUNCATE(a,3)
|
||||
-838:59:59.999999 -838:59:59.999
|
||||
-837:59:59.999999 -837:59:59.999
|
||||
-23:59:59.999999 -23:59:59.999
|
||||
-00:59:59.999999 -00:59:59.999
|
||||
-00:00:59.999999 -00:00:59.999
|
||||
00:00:00.999999 00:00:00.999
|
||||
00:00:59.999999 00:00:59.999
|
||||
00:59:59.999999 00:59:59.999
|
||||
23:59:59.999999 23:59:59.999
|
||||
837:59:59.999999 837:59:59.999
|
||||
838:59:59.999999 838:59:59.999
|
||||
SELECT a, TRUNCATE(a,4) FROM t1;
|
||||
a TRUNCATE(a,4)
|
||||
-838:59:59.999999 -838:59:59.9999
|
||||
-837:59:59.999999 -837:59:59.9999
|
||||
-23:59:59.999999 -23:59:59.9999
|
||||
-00:59:59.999999 -00:59:59.9999
|
||||
-00:00:59.999999 -00:00:59.9999
|
||||
00:00:00.999999 00:00:00.9999
|
||||
00:00:59.999999 00:00:59.9999
|
||||
00:59:59.999999 00:59:59.9999
|
||||
23:59:59.999999 23:59:59.9999
|
||||
837:59:59.999999 837:59:59.9999
|
||||
838:59:59.999999 838:59:59.9999
|
||||
SELECT a, TRUNCATE(a,5) FROM t1;
|
||||
a TRUNCATE(a,5)
|
||||
-838:59:59.999999 -838:59:59.99999
|
||||
-837:59:59.999999 -837:59:59.99999
|
||||
-23:59:59.999999 -23:59:59.99999
|
||||
-00:59:59.999999 -00:59:59.99999
|
||||
-00:00:59.999999 -00:00:59.99999
|
||||
00:00:00.999999 00:00:00.99999
|
||||
00:00:59.999999 00:00:59.99999
|
||||
00:59:59.999999 00:59:59.99999
|
||||
23:59:59.999999 23:59:59.99999
|
||||
837:59:59.999999 837:59:59.99999
|
||||
838:59:59.999999 838:59:59.99999
|
||||
SELECT a, TRUNCATE(a,6) FROM t1;
|
||||
a TRUNCATE(a,6)
|
||||
-838:59:59.999999 -838:59:59.999999
|
||||
-837:59:59.999999 -837:59:59.999999
|
||||
-23:59:59.999999 -23:59:59.999999
|
||||
-00:59:59.999999 -00:59:59.999999
|
||||
-00:00:59.999999 -00:00:59.999999
|
||||
00:00:00.999999 00:00:00.999999
|
||||
00:00:59.999999 00:00:59.999999
|
||||
00:59:59.999999 00:59:59.999999
|
||||
23:59:59.999999 23:59:59.999999
|
||||
837:59:59.999999 837:59:59.999999
|
||||
838:59:59.999999 838:59:59.999999
|
||||
SELECT a, TRUNCATE(a,7) FROM t1;
|
||||
a TRUNCATE(a,7)
|
||||
-838:59:59.999999 -838:59:59.999999
|
||||
-837:59:59.999999 -837:59:59.999999
|
||||
-23:59:59.999999 -23:59:59.999999
|
||||
-00:59:59.999999 -00:59:59.999999
|
||||
-00:00:59.999999 -00:00:59.999999
|
||||
00:00:00.999999 00:00:00.999999
|
||||
00:00:59.999999 00:00:59.999999
|
||||
00:59:59.999999 00:59:59.999999
|
||||
23:59:59.999999 23:59:59.999999
|
||||
837:59:59.999999 837:59:59.999999
|
||||
838:59:59.999999 838:59:59.999999
|
||||
SELECT a, TRUNCATE(a,-1) FROM t1;
|
||||
a TRUNCATE(a,-1)
|
||||
-838:59:59.999999 -838:59:59
|
||||
-837:59:59.999999 -837:59:59
|
||||
-23:59:59.999999 -23:59:59
|
||||
-00:59:59.999999 -00:59:59
|
||||
-00:00:59.999999 -00:00:59
|
||||
00:00:00.999999 00:00:00
|
||||
00:00:59.999999 00:00:59
|
||||
00:59:59.999999 00:59:59
|
||||
23:59:59.999999 23:59:59
|
||||
837:59:59.999999 837:59:59
|
||||
838:59:59.999999 838:59:59
|
||||
SELECT a, TRUNCATE(a,-6) FROM t1;
|
||||
a TRUNCATE(a,-6)
|
||||
-838:59:59.999999 -838:59:59
|
||||
-837:59:59.999999 -837:59:59
|
||||
-23:59:59.999999 -23:59:59
|
||||
-00:59:59.999999 -00:59:59
|
||||
-00:00:59.999999 -00:00:59
|
||||
00:00:00.999999 00:00:00
|
||||
00:00:59.999999 00:00:59
|
||||
00:59:59.999999 00:59:59
|
||||
23:59:59.999999 23:59:59
|
||||
837:59:59.999999 837:59:59
|
||||
838:59:59.999999 838:59:59
|
||||
SELECT a, ROUND(a) FROM t1;
|
||||
a ROUND(a)
|
||||
-838:59:59.999999 -838:59:59
|
||||
-837:59:59.999999 -838:00:00
|
||||
-23:59:59.999999 -24:00:00
|
||||
-00:59:59.999999 -01:00:00
|
||||
-00:00:59.999999 -00:01:00
|
||||
00:00:00.999999 00:00:01
|
||||
00:00:59.999999 00:01:00
|
||||
00:59:59.999999 01:00:00
|
||||
23:59:59.999999 24:00:00
|
||||
837:59:59.999999 838:00:00
|
||||
838:59:59.999999 838:59:59
|
||||
SELECT a, ROUND(a,0) FROM t1;
|
||||
a ROUND(a,0)
|
||||
-838:59:59.999999 -838:59:59
|
||||
-837:59:59.999999 -838:00:00
|
||||
-23:59:59.999999 -24:00:00
|
||||
-00:59:59.999999 -01:00:00
|
||||
-00:00:59.999999 -00:01:00
|
||||
00:00:00.999999 00:00:01
|
||||
00:00:59.999999 00:01:00
|
||||
00:59:59.999999 01:00:00
|
||||
23:59:59.999999 24:00:00
|
||||
837:59:59.999999 838:00:00
|
||||
838:59:59.999999 838:59:59
|
||||
SELECT a, ROUND(a,1) FROM t1;
|
||||
a ROUND(a,1)
|
||||
-838:59:59.999999 -838:59:59.9
|
||||
-837:59:59.999999 -838:00:00.0
|
||||
-23:59:59.999999 -24:00:00.0
|
||||
-00:59:59.999999 -01:00:00.0
|
||||
-00:00:59.999999 -00:01:00.0
|
||||
00:00:00.999999 00:00:01.0
|
||||
00:00:59.999999 00:01:00.0
|
||||
00:59:59.999999 01:00:00.0
|
||||
23:59:59.999999 24:00:00.0
|
||||
837:59:59.999999 838:00:00.0
|
||||
838:59:59.999999 838:59:59.9
|
||||
SELECT a, ROUND(a,2) FROM t1;
|
||||
a ROUND(a,2)
|
||||
-838:59:59.999999 -838:59:59.99
|
||||
-837:59:59.999999 -838:00:00.00
|
||||
-23:59:59.999999 -24:00:00.00
|
||||
-00:59:59.999999 -01:00:00.00
|
||||
-00:00:59.999999 -00:01:00.00
|
||||
00:00:00.999999 00:00:01.00
|
||||
00:00:59.999999 00:01:00.00
|
||||
00:59:59.999999 01:00:00.00
|
||||
23:59:59.999999 24:00:00.00
|
||||
837:59:59.999999 838:00:00.00
|
||||
838:59:59.999999 838:59:59.99
|
||||
SELECT a, ROUND(a,3) FROM t1;
|
||||
a ROUND(a,3)
|
||||
-838:59:59.999999 -838:59:59.999
|
||||
-837:59:59.999999 -838:00:00.000
|
||||
-23:59:59.999999 -24:00:00.000
|
||||
-00:59:59.999999 -01:00:00.000
|
||||
-00:00:59.999999 -00:01:00.000
|
||||
00:00:00.999999 00:00:01.000
|
||||
00:00:59.999999 00:01:00.000
|
||||
00:59:59.999999 01:00:00.000
|
||||
23:59:59.999999 24:00:00.000
|
||||
837:59:59.999999 838:00:00.000
|
||||
838:59:59.999999 838:59:59.999
|
||||
SELECT a, ROUND(a,4) FROM t1;
|
||||
a ROUND(a,4)
|
||||
-838:59:59.999999 -838:59:59.9999
|
||||
-837:59:59.999999 -838:00:00.0000
|
||||
-23:59:59.999999 -24:00:00.0000
|
||||
-00:59:59.999999 -01:00:00.0000
|
||||
-00:00:59.999999 -00:01:00.0000
|
||||
00:00:00.999999 00:00:01.0000
|
||||
00:00:59.999999 00:01:00.0000
|
||||
00:59:59.999999 01:00:00.0000
|
||||
23:59:59.999999 24:00:00.0000
|
||||
837:59:59.999999 838:00:00.0000
|
||||
838:59:59.999999 838:59:59.9999
|
||||
SELECT a, ROUND(a,5) FROM t1;
|
||||
a ROUND(a,5)
|
||||
-838:59:59.999999 -838:59:59.99999
|
||||
-837:59:59.999999 -838:00:00.00000
|
||||
-23:59:59.999999 -24:00:00.00000
|
||||
-00:59:59.999999 -01:00:00.00000
|
||||
-00:00:59.999999 -00:01:00.00000
|
||||
00:00:00.999999 00:00:01.00000
|
||||
00:00:59.999999 00:01:00.00000
|
||||
00:59:59.999999 01:00:00.00000
|
||||
23:59:59.999999 24:00:00.00000
|
||||
837:59:59.999999 838:00:00.00000
|
||||
838:59:59.999999 838:59:59.99999
|
||||
SELECT a, ROUND(a,6) FROM t1;
|
||||
a ROUND(a,6)
|
||||
-838:59:59.999999 -838:59:59.999999
|
||||
-837:59:59.999999 -837:59:59.999999
|
||||
-23:59:59.999999 -23:59:59.999999
|
||||
-00:59:59.999999 -00:59:59.999999
|
||||
-00:00:59.999999 -00:00:59.999999
|
||||
00:00:00.999999 00:00:00.999999
|
||||
00:00:59.999999 00:00:59.999999
|
||||
00:59:59.999999 00:59:59.999999
|
||||
23:59:59.999999 23:59:59.999999
|
||||
837:59:59.999999 837:59:59.999999
|
||||
838:59:59.999999 838:59:59.999999
|
||||
SELECT a, ROUND(a,7) FROM t1;
|
||||
a ROUND(a,7)
|
||||
-838:59:59.999999 -838:59:59.999999
|
||||
-837:59:59.999999 -837:59:59.999999
|
||||
-23:59:59.999999 -23:59:59.999999
|
||||
-00:59:59.999999 -00:59:59.999999
|
||||
-00:00:59.999999 -00:00:59.999999
|
||||
00:00:00.999999 00:00:00.999999
|
||||
00:00:59.999999 00:00:59.999999
|
||||
00:59:59.999999 00:59:59.999999
|
||||
23:59:59.999999 23:59:59.999999
|
||||
837:59:59.999999 837:59:59.999999
|
||||
838:59:59.999999 838:59:59.999999
|
||||
SELECT a, ROUND(a,-1) FROM t1;
|
||||
a ROUND(a,-1)
|
||||
-838:59:59.999999 -838:59:59
|
||||
-837:59:59.999999 -838:00:00
|
||||
-23:59:59.999999 -24:00:00
|
||||
-00:59:59.999999 -01:00:00
|
||||
-00:00:59.999999 -00:01:00
|
||||
00:00:00.999999 00:00:01
|
||||
00:00:59.999999 00:01:00
|
||||
00:59:59.999999 01:00:00
|
||||
23:59:59.999999 24:00:00
|
||||
837:59:59.999999 838:00:00
|
||||
838:59:59.999999 838:59:59
|
||||
SELECT a, ROUND(a,-6) FROM t1;
|
||||
a ROUND(a,-6)
|
||||
-838:59:59.999999 -838:59:59
|
||||
-837:59:59.999999 -838:00:00
|
||||
-23:59:59.999999 -24:00:00
|
||||
-00:59:59.999999 -01:00:00
|
||||
-00:00:59.999999 -00:01:00
|
||||
00:00:00.999999 00:00:01
|
||||
00:00:59.999999 00:01:00
|
||||
00:59:59.999999 01:00:00
|
||||
23:59:59.999999 24:00:00
|
||||
837:59:59.999999 838:00:00
|
||||
838:59:59.999999 838:59:59
|
||||
DROP TABLE t1;
|
||||
SET time_zone=DEFAULT;
|
||||
|
@ -10,3 +10,66 @@ select min(a - interval 1 hour), max(a - interval 1 hour) from t1 where a < 0;
|
||||
drop table t1;
|
||||
|
||||
select cast(1e-6 as time(6));
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Start of 10.4 tests
|
||||
--echo #
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-20397 Support TIMESTAMP, DATETIME, TIME in ROUND() and TRUNCATE()
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a1 TIME(6), a2 TIME(6) NOT NULL);
|
||||
CREATE TABLE t2 AS SELECT
|
||||
ROUND(a1) AS r1,
|
||||
ROUND(a2) AS r2,
|
||||
TRUNCATE(a1,0) AS t1,
|
||||
TRUNCATE(a2,0) AS t2
|
||||
FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
CREATE TABLE t1 (a TIME(6));
|
||||
INSERT INTO t1 VALUES
|
||||
('-838:59:59.999999'),
|
||||
('-837:59:59.999999'),
|
||||
('-23:59:59.999999'),
|
||||
('-00:59:59.999999'),
|
||||
('-00:00:59.999999'),
|
||||
('00:00:00.999999'),
|
||||
('00:00:59.999999'),
|
||||
('00:59:59.999999'),
|
||||
('23:59:59.999999'),
|
||||
('837:59:59.999999'),
|
||||
('838:59:59.999999');
|
||||
|
||||
|
||||
SELECT a, TRUNCATE(a,0) FROM t1;
|
||||
SELECT a, TRUNCATE(a,1) FROM t1;
|
||||
SELECT a, TRUNCATE(a,2) FROM t1;
|
||||
SELECT a, TRUNCATE(a,3) FROM t1;
|
||||
SELECT a, TRUNCATE(a,4) FROM t1;
|
||||
SELECT a, TRUNCATE(a,5) FROM t1;
|
||||
SELECT a, TRUNCATE(a,6) FROM t1;
|
||||
SELECT a, TRUNCATE(a,7) FROM t1;
|
||||
SELECT a, TRUNCATE(a,-1) FROM t1;
|
||||
SELECT a, TRUNCATE(a,-6) FROM t1;
|
||||
|
||||
SELECT a, ROUND(a) FROM t1;
|
||||
SELECT a, ROUND(a,0) FROM t1;
|
||||
SELECT a, ROUND(a,1) FROM t1;
|
||||
SELECT a, ROUND(a,2) FROM t1;
|
||||
SELECT a, ROUND(a,3) FROM t1;
|
||||
SELECT a, ROUND(a,4) FROM t1;
|
||||
SELECT a, ROUND(a,5) FROM t1;
|
||||
SELECT a, ROUND(a,6) FROM t1;
|
||||
SELECT a, ROUND(a,7) FROM t1;
|
||||
SELECT a, ROUND(a,-1) FROM t1;
|
||||
SELECT a, ROUND(a,-6) FROM t1;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
SET time_zone=DEFAULT;
|
||||
|
@ -1267,5 +1267,35 @@ f
|
||||
DROP TABLE t1;
|
||||
SET sql_mode=DEFAULT;
|
||||
#
|
||||
# MDEV-20417 Assertion `(m_ptr == __null) == item->null_value' failed in VDec::VDec(Item*)
|
||||
#
|
||||
CREATE TABLE t1 (a TIMESTAMP(4), b TIMESTAMP DEFAULT 0) ENGINE=MyISAM;
|
||||
INSERT IGNORE INTO t1 VALUES ('2001-01-01','2002-01-01'),('2003-01-01','2004-01-01');
|
||||
SELECT * FROM t1 WHERE DEFAULT(b) - a;
|
||||
a b
|
||||
Warnings:
|
||||
Warning 1916 Got overflow when converting '-20010101000000' to UNSIGNED INT. Value truncated
|
||||
Warning 1916 Got overflow when converting '-20030101000000' to UNSIGNED INT. Value truncated
|
||||
SELECT LEFT('', DEFAULT(b)-a) FROM t1;
|
||||
LEFT('', DEFAULT(b)-a)
|
||||
|
||||
|
||||
Warnings:
|
||||
Warning 1916 Got overflow when converting '-20010101000000' to UNSIGNED INT. Value truncated
|
||||
Warning 1916 Got overflow when converting '-20030101000000' to UNSIGNED INT. Value truncated
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a TIMESTAMP(4), b TIMESTAMP DEFAULT 0) ENGINE=MyISAM;
|
||||
INSERT IGNORE INTO t1 (a) VALUES ('2001-01-01'),('2003-01-01');
|
||||
SELECT * FROM t1 WHERE (SELECT MIN(b) FROM t1) - a;
|
||||
a b
|
||||
Warnings:
|
||||
Warning 1916 Got overflow when converting '-20010101000000' to UNSIGNED INT. Value truncated
|
||||
Warning 1916 Got overflow when converting '-20030101000000' to UNSIGNED INT. Value truncated
|
||||
SELECT (SELECT MIN(b) FROM t1) - a FROM t1;
|
||||
(SELECT MIN(b) FROM t1) - a
|
||||
-20010101000000.0000
|
||||
-20030101000000.0000
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# End of 10.4 tests
|
||||
#
|
||||
|
@ -837,6 +837,24 @@ SELECT GREATEST(a,b) AS f FROM t1 ORDER BY 1 DESC;
|
||||
DROP TABLE t1;
|
||||
SET sql_mode=DEFAULT;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-20417 Assertion `(m_ptr == __null) == item->null_value' failed in VDec::VDec(Item*)
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a TIMESTAMP(4), b TIMESTAMP DEFAULT 0) ENGINE=MyISAM;
|
||||
INSERT IGNORE INTO t1 VALUES ('2001-01-01','2002-01-01'),('2003-01-01','2004-01-01');
|
||||
SELECT * FROM t1 WHERE DEFAULT(b) - a;
|
||||
SELECT LEFT('', DEFAULT(b)-a) FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
CREATE TABLE t1 (a TIMESTAMP(4), b TIMESTAMP DEFAULT 0) ENGINE=MyISAM;
|
||||
INSERT IGNORE INTO t1 (a) VALUES ('2001-01-01'),('2003-01-01');
|
||||
SELECT * FROM t1 WHERE (SELECT MIN(b) FROM t1) - a;
|
||||
SELECT (SELECT MIN(b) FROM t1) - a FROM t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.4 tests
|
||||
--echo #
|
||||
|
@ -17,8 +17,8 @@ a
|
||||
2010-12-11 01:02:03.456
|
||||
2010-12-11 03:04:05.789
|
||||
2010-12-11 15:47:11.123
|
||||
select truncate(a, 6) from t1;
|
||||
truncate(a, 6)
|
||||
select cast(a AS double(30,6)) from t1;
|
||||
cast(a AS double(30,6))
|
||||
0.000000
|
||||
20101211002003.120000
|
||||
20101211010203.457031
|
||||
@ -333,3 +333,298 @@ t1 CREATE TABLE `t1` (
|
||||
`a` timestamp(5) NOT NULL DEFAULT '0000-00-00 00:00:00.00000' ON UPDATE current_timestamp(5)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
#
|
||||
# Start of 10.4 tests
|
||||
#
|
||||
#
|
||||
# MDEV-20397 Support TIMESTAMP, DATETIME, TIME in ROUND() and TRUNCATE()
|
||||
#
|
||||
# ROUND(timestamp) and TRUNCATE(timestamp) currently return DATETIME.
|
||||
# This may change in the future to return TIMESTAMP.
|
||||
CREATE TABLE t1 (a1 TIMESTAMP(6) NULL DEFAULT '2001-01-01 00:00:00', a2 TIMESTAMP(6) NOT NULL);
|
||||
CREATE TABLE t2 AS SELECT
|
||||
ROUND(a1) AS r1,
|
||||
ROUND(a2) AS r2,
|
||||
TRUNCATE(a1,0) AS t1,
|
||||
TRUNCATE(a2,0) AS t2
|
||||
FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`r1` datetime DEFAULT NULL,
|
||||
`r2` datetime DEFAULT NULL,
|
||||
`t1` datetime DEFAULT NULL,
|
||||
`t2` datetime NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
SET time_zone='+00:00';
|
||||
CREATE TABLE t1 (a TIMESTAMP(6));
|
||||
INSERT INTO t1 VALUES
|
||||
('1970-01-01 00:00:01.999999'),
|
||||
('2000-01-01 00:00:00.999999'),
|
||||
('2000-01-01 23:59:59.999999'),
|
||||
('2000-02-29 23:59:59.999999'),
|
||||
('2000-12-31 23:59:59.999999'),
|
||||
('2001-01-01 00:00:00.999999'),
|
||||
('2001-01-01 23:59:59.999999'),
|
||||
('2001-02-28 23:59:59.999999'),
|
||||
('2001-12-31 23:59:59.999999'),
|
||||
('2038-01-19 03:14:07.999999');
|
||||
SELECT a, TRUNCATE(a,0) FROM t1;
|
||||
a TRUNCATE(a,0)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:01
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:00
|
||||
2000-01-01 23:59:59.999999 2000-01-01 23:59:59
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:00
|
||||
2001-01-01 23:59:59.999999 2001-01-01 23:59:59
|
||||
2001-02-28 23:59:59.999999 2001-02-28 23:59:59
|
||||
2001-12-31 23:59:59.999999 2001-12-31 23:59:59
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:07
|
||||
SELECT a, TRUNCATE(a,1) FROM t1;
|
||||
a TRUNCATE(a,1)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:01.9
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:00.9
|
||||
2000-01-01 23:59:59.999999 2000-01-01 23:59:59.9
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.9
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.9
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:00.9
|
||||
2001-01-01 23:59:59.999999 2001-01-01 23:59:59.9
|
||||
2001-02-28 23:59:59.999999 2001-02-28 23:59:59.9
|
||||
2001-12-31 23:59:59.999999 2001-12-31 23:59:59.9
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:07.9
|
||||
SELECT a, TRUNCATE(a,2) FROM t1;
|
||||
a TRUNCATE(a,2)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:01.99
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:00.99
|
||||
2000-01-01 23:59:59.999999 2000-01-01 23:59:59.99
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.99
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.99
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:00.99
|
||||
2001-01-01 23:59:59.999999 2001-01-01 23:59:59.99
|
||||
2001-02-28 23:59:59.999999 2001-02-28 23:59:59.99
|
||||
2001-12-31 23:59:59.999999 2001-12-31 23:59:59.99
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:07.99
|
||||
SELECT a, TRUNCATE(a,3) FROM t1;
|
||||
a TRUNCATE(a,3)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:01.999
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:00.999
|
||||
2000-01-01 23:59:59.999999 2000-01-01 23:59:59.999
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.999
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.999
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:00.999
|
||||
2001-01-01 23:59:59.999999 2001-01-01 23:59:59.999
|
||||
2001-02-28 23:59:59.999999 2001-02-28 23:59:59.999
|
||||
2001-12-31 23:59:59.999999 2001-12-31 23:59:59.999
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:07.999
|
||||
SELECT a, TRUNCATE(a,4) FROM t1;
|
||||
a TRUNCATE(a,4)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:01.9999
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:00.9999
|
||||
2000-01-01 23:59:59.999999 2000-01-01 23:59:59.9999
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.9999
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.9999
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:00.9999
|
||||
2001-01-01 23:59:59.999999 2001-01-01 23:59:59.9999
|
||||
2001-02-28 23:59:59.999999 2001-02-28 23:59:59.9999
|
||||
2001-12-31 23:59:59.999999 2001-12-31 23:59:59.9999
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:07.9999
|
||||
SELECT a, TRUNCATE(a,5) FROM t1;
|
||||
a TRUNCATE(a,5)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:01.99999
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:00.99999
|
||||
2000-01-01 23:59:59.999999 2000-01-01 23:59:59.99999
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.99999
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.99999
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:00.99999
|
||||
2001-01-01 23:59:59.999999 2001-01-01 23:59:59.99999
|
||||
2001-02-28 23:59:59.999999 2001-02-28 23:59:59.99999
|
||||
2001-12-31 23:59:59.999999 2001-12-31 23:59:59.99999
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:07.99999
|
||||
SELECT a, TRUNCATE(a,6) FROM t1;
|
||||
a TRUNCATE(a,6)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:01.999999
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:00.999999
|
||||
2000-01-01 23:59:59.999999 2000-01-01 23:59:59.999999
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.999999
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.999999
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:00.999999
|
||||
2001-01-01 23:59:59.999999 2001-01-01 23:59:59.999999
|
||||
2001-02-28 23:59:59.999999 2001-02-28 23:59:59.999999
|
||||
2001-12-31 23:59:59.999999 2001-12-31 23:59:59.999999
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:07.999999
|
||||
SELECT a, TRUNCATE(a,7) FROM t1;
|
||||
a TRUNCATE(a,7)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:01.999999
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:00.999999
|
||||
2000-01-01 23:59:59.999999 2000-01-01 23:59:59.999999
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.999999
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.999999
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:00.999999
|
||||
2001-01-01 23:59:59.999999 2001-01-01 23:59:59.999999
|
||||
2001-02-28 23:59:59.999999 2001-02-28 23:59:59.999999
|
||||
2001-12-31 23:59:59.999999 2001-12-31 23:59:59.999999
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:07.999999
|
||||
SELECT a, TRUNCATE(a,-1) FROM t1;
|
||||
a TRUNCATE(a,-1)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:01
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:00
|
||||
2000-01-01 23:59:59.999999 2000-01-01 23:59:59
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:00
|
||||
2001-01-01 23:59:59.999999 2001-01-01 23:59:59
|
||||
2001-02-28 23:59:59.999999 2001-02-28 23:59:59
|
||||
2001-12-31 23:59:59.999999 2001-12-31 23:59:59
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:07
|
||||
SELECT a, TRUNCATE(a,-6) FROM t1;
|
||||
a TRUNCATE(a,-6)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:01
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:00
|
||||
2000-01-01 23:59:59.999999 2000-01-01 23:59:59
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:00
|
||||
2001-01-01 23:59:59.999999 2001-01-01 23:59:59
|
||||
2001-02-28 23:59:59.999999 2001-02-28 23:59:59
|
||||
2001-12-31 23:59:59.999999 2001-12-31 23:59:59
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:07
|
||||
SELECT a, ROUND(a) FROM t1;
|
||||
a ROUND(a)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:02
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:01
|
||||
2000-01-01 23:59:59.999999 2000-01-02 00:00:00
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:01
|
||||
2001-01-01 23:59:59.999999 2001-01-02 00:00:00
|
||||
2001-02-28 23:59:59.999999 2001-03-01 00:00:00
|
||||
2001-12-31 23:59:59.999999 2002-01-01 00:00:00
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:08
|
||||
SELECT a, ROUND(a,0) FROM t1;
|
||||
a ROUND(a,0)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:02
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:01
|
||||
2000-01-01 23:59:59.999999 2000-01-02 00:00:00
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:01
|
||||
2001-01-01 23:59:59.999999 2001-01-02 00:00:00
|
||||
2001-02-28 23:59:59.999999 2001-03-01 00:00:00
|
||||
2001-12-31 23:59:59.999999 2002-01-01 00:00:00
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:08
|
||||
SELECT a, ROUND(a,1) FROM t1;
|
||||
a ROUND(a,1)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:02.0
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:01.0
|
||||
2000-01-01 23:59:59.999999 2000-01-02 00:00:00.0
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00.0
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00.0
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:01.0
|
||||
2001-01-01 23:59:59.999999 2001-01-02 00:00:00.0
|
||||
2001-02-28 23:59:59.999999 2001-03-01 00:00:00.0
|
||||
2001-12-31 23:59:59.999999 2002-01-01 00:00:00.0
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:08.0
|
||||
SELECT a, ROUND(a,2) FROM t1;
|
||||
a ROUND(a,2)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:02.00
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:01.00
|
||||
2000-01-01 23:59:59.999999 2000-01-02 00:00:00.00
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00.00
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00.00
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:01.00
|
||||
2001-01-01 23:59:59.999999 2001-01-02 00:00:00.00
|
||||
2001-02-28 23:59:59.999999 2001-03-01 00:00:00.00
|
||||
2001-12-31 23:59:59.999999 2002-01-01 00:00:00.00
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:08.00
|
||||
SELECT a, ROUND(a,3) FROM t1;
|
||||
a ROUND(a,3)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:02.000
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:01.000
|
||||
2000-01-01 23:59:59.999999 2000-01-02 00:00:00.000
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00.000
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00.000
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:01.000
|
||||
2001-01-01 23:59:59.999999 2001-01-02 00:00:00.000
|
||||
2001-02-28 23:59:59.999999 2001-03-01 00:00:00.000
|
||||
2001-12-31 23:59:59.999999 2002-01-01 00:00:00.000
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:08.000
|
||||
SELECT a, ROUND(a,4) FROM t1;
|
||||
a ROUND(a,4)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:02.0000
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:01.0000
|
||||
2000-01-01 23:59:59.999999 2000-01-02 00:00:00.0000
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00.0000
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00.0000
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:01.0000
|
||||
2001-01-01 23:59:59.999999 2001-01-02 00:00:00.0000
|
||||
2001-02-28 23:59:59.999999 2001-03-01 00:00:00.0000
|
||||
2001-12-31 23:59:59.999999 2002-01-01 00:00:00.0000
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:08.0000
|
||||
SELECT a, ROUND(a,5) FROM t1;
|
||||
a ROUND(a,5)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:02.00000
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:01.00000
|
||||
2000-01-01 23:59:59.999999 2000-01-02 00:00:00.00000
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00.00000
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00.00000
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:01.00000
|
||||
2001-01-01 23:59:59.999999 2001-01-02 00:00:00.00000
|
||||
2001-02-28 23:59:59.999999 2001-03-01 00:00:00.00000
|
||||
2001-12-31 23:59:59.999999 2002-01-01 00:00:00.00000
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:08.00000
|
||||
SELECT a, ROUND(a,6) FROM t1;
|
||||
a ROUND(a,6)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:01.999999
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:00.999999
|
||||
2000-01-01 23:59:59.999999 2000-01-01 23:59:59.999999
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.999999
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.999999
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:00.999999
|
||||
2001-01-01 23:59:59.999999 2001-01-01 23:59:59.999999
|
||||
2001-02-28 23:59:59.999999 2001-02-28 23:59:59.999999
|
||||
2001-12-31 23:59:59.999999 2001-12-31 23:59:59.999999
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:07.999999
|
||||
SELECT a, ROUND(a,7) FROM t1;
|
||||
a ROUND(a,7)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:01.999999
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:00.999999
|
||||
2000-01-01 23:59:59.999999 2000-01-01 23:59:59.999999
|
||||
2000-02-29 23:59:59.999999 2000-02-29 23:59:59.999999
|
||||
2000-12-31 23:59:59.999999 2000-12-31 23:59:59.999999
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:00.999999
|
||||
2001-01-01 23:59:59.999999 2001-01-01 23:59:59.999999
|
||||
2001-02-28 23:59:59.999999 2001-02-28 23:59:59.999999
|
||||
2001-12-31 23:59:59.999999 2001-12-31 23:59:59.999999
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:07.999999
|
||||
SELECT a, ROUND(a,-1) FROM t1;
|
||||
a ROUND(a,-1)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:02
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:01
|
||||
2000-01-01 23:59:59.999999 2000-01-02 00:00:00
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:01
|
||||
2001-01-01 23:59:59.999999 2001-01-02 00:00:00
|
||||
2001-02-28 23:59:59.999999 2001-03-01 00:00:00
|
||||
2001-12-31 23:59:59.999999 2002-01-01 00:00:00
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:08
|
||||
SELECT a, ROUND(a,-6) FROM t1;
|
||||
a ROUND(a,-6)
|
||||
1970-01-01 00:00:01.999999 1970-01-01 00:00:02
|
||||
2000-01-01 00:00:00.999999 2000-01-01 00:00:01
|
||||
2000-01-01 23:59:59.999999 2000-01-02 00:00:00
|
||||
2000-02-29 23:59:59.999999 2000-03-01 00:00:00
|
||||
2000-12-31 23:59:59.999999 2001-01-01 00:00:00
|
||||
2001-01-01 00:00:00.999999 2001-01-01 00:00:01
|
||||
2001-01-01 23:59:59.999999 2001-01-02 00:00:00
|
||||
2001-02-28 23:59:59.999999 2001-03-01 00:00:00
|
||||
2001-12-31 23:59:59.999999 2002-01-01 00:00:00
|
||||
2038-01-19 03:14:07.999999 2038-01-19 03:14:08
|
||||
DROP TABLE t1;
|
||||
SET time_zone=DEFAULT;
|
||||
#
|
||||
# End of 10.4 tests
|
||||
#
|
||||
|
@ -40,3 +40,73 @@ show create table t1;
|
||||
create or replace table t1 (a timestamp(5) on update current_timestamp(6));
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # Start of 10.4 tests
|
||||
--echo #
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-20397 Support TIMESTAMP, DATETIME, TIME in ROUND() and TRUNCATE()
|
||||
--echo #
|
||||
|
||||
--echo # ROUND(timestamp) and TRUNCATE(timestamp) currently return DATETIME.
|
||||
--echo # This may change in the future to return TIMESTAMP.
|
||||
|
||||
CREATE TABLE t1 (a1 TIMESTAMP(6) NULL DEFAULT '2001-01-01 00:00:00', a2 TIMESTAMP(6) NOT NULL);
|
||||
CREATE TABLE t2 AS SELECT
|
||||
ROUND(a1) AS r1,
|
||||
ROUND(a2) AS r2,
|
||||
TRUNCATE(a1,0) AS t1,
|
||||
TRUNCATE(a2,0) AS t2
|
||||
FROM t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
SET time_zone='+00:00';
|
||||
|
||||
CREATE TABLE t1 (a TIMESTAMP(6));
|
||||
INSERT INTO t1 VALUES
|
||||
('1970-01-01 00:00:01.999999'),
|
||||
('2000-01-01 00:00:00.999999'),
|
||||
('2000-01-01 23:59:59.999999'),
|
||||
('2000-02-29 23:59:59.999999'),
|
||||
('2000-12-31 23:59:59.999999'),
|
||||
('2001-01-01 00:00:00.999999'),
|
||||
('2001-01-01 23:59:59.999999'),
|
||||
('2001-02-28 23:59:59.999999'),
|
||||
('2001-12-31 23:59:59.999999'),
|
||||
('2038-01-19 03:14:07.999999');
|
||||
|
||||
SELECT a, TRUNCATE(a,0) FROM t1;
|
||||
SELECT a, TRUNCATE(a,1) FROM t1;
|
||||
SELECT a, TRUNCATE(a,2) FROM t1;
|
||||
SELECT a, TRUNCATE(a,3) FROM t1;
|
||||
SELECT a, TRUNCATE(a,4) FROM t1;
|
||||
SELECT a, TRUNCATE(a,5) FROM t1;
|
||||
SELECT a, TRUNCATE(a,6) FROM t1;
|
||||
SELECT a, TRUNCATE(a,7) FROM t1;
|
||||
SELECT a, TRUNCATE(a,-1) FROM t1;
|
||||
SELECT a, TRUNCATE(a,-6) FROM t1;
|
||||
|
||||
SELECT a, ROUND(a) FROM t1;
|
||||
SELECT a, ROUND(a,0) FROM t1;
|
||||
SELECT a, ROUND(a,1) FROM t1;
|
||||
SELECT a, ROUND(a,2) FROM t1;
|
||||
SELECT a, ROUND(a,3) FROM t1;
|
||||
SELECT a, ROUND(a,4) FROM t1;
|
||||
SELECT a, ROUND(a,5) FROM t1;
|
||||
SELECT a, ROUND(a,6) FROM t1;
|
||||
SELECT a, ROUND(a,7) FROM t1;
|
||||
SELECT a, ROUND(a,-1) FROM t1;
|
||||
SELECT a, ROUND(a,-6) FROM t1;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
SET time_zone=DEFAULT;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.4 tests
|
||||
--echo #
|
||||
|
@ -449,27 +449,37 @@ sub check_wsrep_support() {
|
||||
# ADD scripts to $PATH to that wsrep_sst_* can be found
|
||||
my ($spath) = grep { -f "$_/wsrep_sst_rsync"; } "$bindir/scripts", $path_client_bindir;
|
||||
mtr_error("No SST scripts") unless $spath;
|
||||
$ENV{PATH}="$spath:$ENV{PATH}";
|
||||
my $separator= (IS_WINDOWS) ? ';' : ':';
|
||||
$ENV{PATH}="$spath$separator$ENV{PATH}";
|
||||
|
||||
# ADD mysql client library path to path so that wsrep_notify_cmd can find mysql
|
||||
# client for loading the tables. (Don't assume each machine has mysql install)
|
||||
my ($cpath) = grep { -f "$_/mysql"; } "$bindir/scripts", $path_client_bindir;
|
||||
mtr_error("No scritps") unless $cpath;
|
||||
$ENV{PATH}="$cpath:$ENV{PATH}" unless $cpath eq $spath;
|
||||
$ENV{PATH}="$cpath$separator$ENV{PATH}" unless $cpath eq $spath;
|
||||
|
||||
# ADD my_print_defaults script path to path so that SST scripts can find it
|
||||
my ($epath) = grep { -f "$_/my_print_defaults"; } "$bindir/extra", $path_client_bindir;
|
||||
my $my_print_defaults_exe=
|
||||
mtr_exe_maybe_exists(
|
||||
"$bindir/extra/my_print_defaults",
|
||||
"$path_client_bindir/my_print_defaults");
|
||||
my $epath= "";
|
||||
if ($my_print_defaults_exe ne "") {
|
||||
$epath= dirname($my_print_defaults_exe);
|
||||
}
|
||||
mtr_error("No my_print_defaults") unless $epath;
|
||||
$ENV{PATH}="$epath:$ENV{PATH}" unless ($epath eq $spath) or
|
||||
$ENV{PATH}="$epath$separator$ENV{PATH}" unless ($epath eq $spath) or
|
||||
($epath eq $cpath);
|
||||
|
||||
$extra_path= $epath;
|
||||
|
||||
if (!IS_WINDOWS) {
|
||||
if (which("socat")) {
|
||||
$ENV{MTR_GALERA_TFMT}="socat";
|
||||
} elsif (which("nc")) {
|
||||
$ENV{MTR_GALERA_TFMT}="nc";
|
||||
}
|
||||
}
|
||||
|
||||
# Check whether WSREP_PROVIDER environment variable is set.
|
||||
if (defined $ENV{'WSREP_PROVIDER'}) {
|
||||
@ -515,8 +525,9 @@ sub check_mariabackup_support() {
|
||||
"$bindir/extra/mariabackup$opt_vs_config/mariabackup",
|
||||
"$path_client_bindir/mariabackup");
|
||||
if ($mariabackup_exe ne "") {
|
||||
my ($bpath) = grep { -f "$_/mariabackup"; } "$bindir/extra/mariabackup$opt_vs_config", $path_client_bindir;
|
||||
$ENV{PATH}="$bpath:$ENV{PATH}" unless $bpath eq $extra_path;
|
||||
my $bpath= dirname($mariabackup_exe);
|
||||
my $separator= (IS_WINDOWS) ? ';' : ':';
|
||||
$ENV{PATH}="$bpath$separator$ENV{PATH}" unless $bpath eq $extra_path;
|
||||
|
||||
$mariabackup_path= $bpath;
|
||||
|
||||
|
@ -50,11 +50,11 @@ sub skip_combinations {
|
||||
$skip{'include/have_mariabackup.inc'} = 'Need mariabackup'
|
||||
unless ::have_mariabackup();
|
||||
|
||||
$skip{'include/have_mariabackup.inc'} = 'Need ss'
|
||||
unless ::which("ss");
|
||||
$skip{'include/have_mariabackup.inc'} = 'Need socket statistics utility'
|
||||
unless IS_WINDOWS || ::which("ss");
|
||||
|
||||
$skip{'include/have_mariabackup.inc'} = 'Need socat or nc'
|
||||
unless $ENV{MTR_GALERA_TFMT};
|
||||
unless IS_WINDOWS || $ENV{MTR_GALERA_TFMT};
|
||||
|
||||
$skip{'include/have_garbd.inc'} = 'Need garbd'
|
||||
unless ::have_garbd();
|
||||
|
@ -150,16 +150,16 @@ RESET MASTER;
|
||||
--echo # Test case for DROP query.
|
||||
|
||||
--connection default
|
||||
CREATE TABLE t1 (a INT) ENGINE=INNODB;
|
||||
CREATE TABLE t2 (a INT) ENGINE=INNODB;
|
||||
|
||||
--connection con1
|
||||
CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB;
|
||||
CREATE TEMPORARY TABLE t2 (b BLOB) ENGINE=INNODB;
|
||||
|
||||
--connection default
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
|
||||
--connection con1
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
|
||||
--connection default
|
||||
--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/bug28642318.sql
|
||||
|
@ -88,13 +88,13 @@ DROP TABLE IF EXISTS t1;
|
||||
RESET MASTER;
|
||||
# Test case for DROP query.
|
||||
connection default;
|
||||
CREATE TABLE t1 (a INT) ENGINE=INNODB;
|
||||
CREATE TABLE t2 (a INT) ENGINE=INNODB;
|
||||
connection con1;
|
||||
CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB;
|
||||
CREATE TEMPORARY TABLE t2 (b BLOB) ENGINE=INNODB;
|
||||
connection default;
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
connection con1;
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
connection default;
|
||||
# DROP table query fails with unknown table error without patch.
|
||||
# Clean up
|
||||
|
@ -116,13 +116,13 @@ DROP TABLE IF EXISTS t1;
|
||||
RESET MASTER;
|
||||
# Test case for DROP query.
|
||||
connection default;
|
||||
CREATE TABLE t1 (a INT) ENGINE=INNODB;
|
||||
CREATE TABLE t2 (a INT) ENGINE=INNODB;
|
||||
connection con1;
|
||||
CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB;
|
||||
CREATE TEMPORARY TABLE t2 (b BLOB) ENGINE=INNODB;
|
||||
connection default;
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
connection con1;
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
connection default;
|
||||
# DROP table query fails with unknown table error without patch.
|
||||
# Clean up
|
||||
|
@ -741,21 +741,21 @@ a b
|
||||
explain extended select * from t1
|
||||
where a in (values (1));
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
3 MATERIALIZED <derived2> ALL NULL NULL NULL NULL 2 100.00
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" semi join ((values (1)) "tvc_0") where "test"."t1"."a" = "tvc_0"."1"
|
||||
Note 1003 select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" semi join ((values (1)) "tvc_0") where 1
|
||||
explain extended select * from t1
|
||||
where a in (select * from (values (1)) as tvc_0);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" semi join ((values (1)) "tvc_0") where "test"."t1"."a" = "tvc_0"."1"
|
||||
Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" semi join ((values (1)) "tvc_0") where 1
|
||||
# IN-subquery with VALUES structure(s) : UNION with VALUES on the first place
|
||||
select * from t1
|
||||
where a in (values (1) union select 2);
|
||||
@ -976,21 +976,21 @@ a b
|
||||
explain extended select * from t1
|
||||
where a = any (values (1),(2));
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
3 MATERIALIZED <derived2> ALL NULL NULL NULL NULL 2 100.00
|
||||
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" semi join ((values (1),(2)) "tvc_0") where "test"."t1"."a" = "tvc_0"."1"
|
||||
Note 1003 select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" semi join ((values (1),(2)) "tvc_0") where 1
|
||||
explain extended select * from t1
|
||||
where a = any (select * from (values (1),(2)) as tvc_0);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" semi join ((values (1),(2)) "tvc_0") where "test"."t1"."a" = "tvc_0"."1"
|
||||
Note 1003 /* select#1 */ select "test"."t1"."a" AS "a","test"."t1"."b" AS "b" from "test"."t1" semi join ((values (1),(2)) "tvc_0") where 1
|
||||
# ANY-subquery with VALUES structure(s) : UNION with VALUES on the first place
|
||||
select * from t1
|
||||
where a = any (values (1) union select 2);
|
||||
|
26
mysql-test/suite/encryption/r/file_creation.result
Normal file
26
mysql-test/suite/encryption/r/file_creation.result
Normal file
@ -0,0 +1,26 @@
|
||||
SET GLOBAL innodb_encrypt_tables = ON;
|
||||
SET GLOBAL innodb_encryption_threads = 1;
|
||||
SET GLOBAL innodb_max_dirty_pages_pct = 99;
|
||||
SHOW VARIABLES LIKE 'innodb_encrypt%';
|
||||
Variable_name Value
|
||||
innodb_encrypt_log OFF
|
||||
innodb_encrypt_tables ON
|
||||
innodb_encrypt_temporary_tables OFF
|
||||
innodb_encryption_rotate_key_age 1
|
||||
innodb_encryption_rotation_iops 100
|
||||
innodb_encryption_threads 1
|
||||
CREATE TABLE t1(f1 INT NOT NULL, f2 CHAR(255), f3 CHAR(255),
|
||||
f4 CHAR(255), f5 CHAR(255))ENGINE=INNODB;
|
||||
INSERT INTO t1 VALUES(1, "mysql", "mariadb", "batman", "superman");
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
# Wait max 10 min for key encryption threads to encrypt all spaces
|
||||
OPTIMIZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
|
||||
test.t1 optimize status OK
|
||||
ALTER TABLE t1 FORCE;
|
||||
# Kill the server
|
||||
DROP TABLE t1;
|
1
mysql-test/suite/encryption/t/file_creation.opt
Normal file
1
mysql-test/suite/encryption/t/file_creation.opt
Normal file
@ -0,0 +1 @@
|
||||
--innodb-tablespaces-encryption
|
41
mysql-test/suite/encryption/t/file_creation.test
Normal file
41
mysql-test/suite/encryption/t/file_creation.test
Normal file
@ -0,0 +1,41 @@
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_example_key_management_plugin.inc
|
||||
let $restart_noprint=2;
|
||||
# embedded does not support restart
|
||||
-- source include/not_embedded.inc
|
||||
|
||||
#
|
||||
# MDEV-19348 MariaBackup prepare fails with InnoDB: Database page corruption
|
||||
# on disk or a failed file read
|
||||
#
|
||||
|
||||
SET GLOBAL innodb_encrypt_tables = ON;
|
||||
SET GLOBAL innodb_encryption_threads = 1;
|
||||
SET GLOBAL innodb_max_dirty_pages_pct = 99;
|
||||
SHOW VARIABLES LIKE 'innodb_encrypt%';
|
||||
|
||||
CREATE TABLE t1(f1 INT NOT NULL, f2 CHAR(255), f3 CHAR(255),
|
||||
f4 CHAR(255), f5 CHAR(255))ENGINE=INNODB;
|
||||
|
||||
INSERT INTO t1 VALUES(1, "mysql", "mariadb", "batman", "superman");
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
INSERT INTO t1 SELECT * FROM t1;
|
||||
|
||||
--let $tables_count= `select count(*) + 1 from information_schema.tables where engine = 'InnoDB'`
|
||||
|
||||
--echo # Wait max 10 min for key encryption threads to encrypt all spaces
|
||||
--let $wait_timeout= 600
|
||||
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
|
||||
--source include/wait_condition.inc
|
||||
|
||||
OPTIMIZE TABLE t1;
|
||||
|
||||
--source ../../suite/innodb/include/no_checkpoint_start.inc
|
||||
ALTER TABLE t1 FORCE;
|
||||
--let CLEANUP_IF_CHECKPOINT=DROP TABLE t1;
|
||||
--source ../../suite/innodb/include/no_checkpoint_end.inc
|
||||
|
||||
--source include/start_mysqld.inc
|
||||
DROP TABLE t1;
|
@ -7,7 +7,6 @@ WHERE name LIKE 'thread/sql/wsrep%'
|
||||
ORDER BY name;
|
||||
name thread/sql/wsrep_applier_thread
|
||||
name thread/sql/wsrep_rollbacker_thread
|
||||
name thread/sql/wsrep_rollbacker_thread
|
||||
use test;
|
||||
create table t1 (a int not null primary key) engine=innodb;
|
||||
insert into t1 values (1),(2);
|
||||
|
@ -1,6 +1,5 @@
|
||||
--source include/galera_cluster.inc
|
||||
|
||||
|
||||
--connection node_1
|
||||
|
||||
create database cardtest02;
|
||||
@ -45,16 +44,30 @@ let $table_rows1 = `SELECT table_rows from information_schema.tables WHERE TABLE
|
||||
let $avg_row_length1 = `SELECT avg_row_length from information_schema.tables WHERE TABLE_NAME = 'cardtest_tbl'`;
|
||||
let $data_length1 = `SELECT data_length from information_schema.tables WHERE TABLE_NAME = 'cardtest_tbl'`;
|
||||
|
||||
--let $wait_timeout=600
|
||||
--let $wait_condition = SELECT table_rows = 301 from information_schema.tables WHERE TABLE_NAME = 'cardtest_tbl';
|
||||
--source include/wait_condition.inc
|
||||
|
||||
select count(*) from cardtest_tbl;
|
||||
|
||||
let $cardinality1 = `SELECT cardinality from information_schema.statistics WHERE TABLE_NAME = 'cardtest_tbl'`;
|
||||
let $table_rows1 = `SELECT table_rows from information_schema.tables WHERE TABLE_NAME = 'cardtest_tbl'`;
|
||||
let $avg_row_length1 = `SELECT avg_row_length from information_schema.tables WHERE TABLE_NAME = 'cardtest_tbl'`;
|
||||
let $data_length1 = `SELECT data_length from information_schema.tables WHERE TABLE_NAME = 'cardtest_tbl'`;
|
||||
|
||||
--connection node_2
|
||||
set session wsrep_sync_wait=15;
|
||||
use cardtest02;
|
||||
|
||||
--let $wait_timeout=600
|
||||
--let $wait_condition = SELECT table_rows = 301 from information_schema.tables WHERE TABLE_NAME = 'cardtest_tbl';
|
||||
--source include/wait_condition.inc
|
||||
|
||||
select count(*) from cardtest_tbl;
|
||||
|
||||
if (`SELECT cardinality <> $cardinality1 from information_schema.statistics WHERE TABLE_NAME = 'cardtest_tbl'`)
|
||||
{
|
||||
SELECT cardinality from from information_schema.statistics WHERE TABLE_NAME = 'cardtest_tbl';
|
||||
SELECT cardinality from information_schema.statistics WHERE TABLE_NAME = 'cardtest_tbl';
|
||||
}
|
||||
if (`SELECT table_rows <> $table_rows1 from information_schema.tables WHERE TABLE_NAME = 'cardtest_tbl'`)
|
||||
{
|
||||
|
@ -699,8 +699,8 @@ WHERE t4.c1 < 'o'
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where
|
||||
@ -754,8 +754,8 @@ WHERE t4.c1 < 'o'
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where
|
||||
@ -810,8 +810,8 @@ WHERE t4.c1 < 'o'
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where
|
||||
@ -874,8 +874,8 @@ WHERE t4.c1 < 'o'
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where
|
||||
|
@ -1325,8 +1325,8 @@ WHERE t4.c1 < 'o'
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY,v_idx PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where
|
||||
@ -1381,8 +1381,8 @@ WHERE t4.c1 < 'o'
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY,v_idx,v_idx2 PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where
|
||||
@ -1439,8 +1439,8 @@ WHERE t4.c1 < 'o'
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY,v_idx2 PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where
|
||||
@ -1506,8 +1506,8 @@ WHERE t4.c1 < 'o'
|
||||
)
|
||||
AND t1.i1 <= t3.i2_key;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 eq_ref PRIMARY,v_idx PRIMARY 4 test.t4.i1 1 Using where
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED t4 ALL NULL NULL NULL NULL 3 Using where
|
||||
|
@ -161,3 +161,62 @@ c d
|
||||
6 30
|
||||
drop table t2, t1;
|
||||
drop user foo;
|
||||
#
|
||||
# MDEV-17187 table doesn't exist in engine after ALTER other tables
|
||||
# with CONSTRAINTs
|
||||
#
|
||||
set foreign_key_checks=on;
|
||||
create table t1 (id int not null primary key) engine=innodb;
|
||||
create table t2 (id int not null primary key, fid int not null,
|
||||
CONSTRAINT fk_fid FOREIGN KEY (fid) REFERENCES t1 (id))engine=innodb;
|
||||
insert into t1 values (1), (2), (3);
|
||||
insert into t2 values (1, 1), (2, 1), (3, 2);
|
||||
set foreign_key_checks=off;
|
||||
alter table t2 drop index fk_fid;
|
||||
set foreign_key_checks=on;
|
||||
delete from t1 where id=2;
|
||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk_fid` FOREIGN KEY (`fid`) REFERENCES `t1` (`id`))
|
||||
insert into t2 values(4, 99);
|
||||
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `fk_fid` FOREIGN KEY (`fid`) REFERENCES `t1` (`id`))
|
||||
select * from t1;
|
||||
id
|
||||
1
|
||||
2
|
||||
3
|
||||
select * from t2;
|
||||
id fid
|
||||
1 1
|
||||
2 1
|
||||
3 2
|
||||
set foreign_key_checks=off;
|
||||
delete from t1 where id=2;
|
||||
insert into t2 values(4, 99);
|
||||
set foreign_key_checks=on;
|
||||
select * from t1;
|
||||
id
|
||||
1
|
||||
3
|
||||
select * from t2;
|
||||
id fid
|
||||
1 1
|
||||
2 1
|
||||
3 2
|
||||
4 99
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
show create table t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`id` int(11) NOT NULL,
|
||||
`fid` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_fid` FOREIGN KEY (`fid`) REFERENCES `t1` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
drop table t1,t2;
|
||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
|
||||
drop table t1,t2;
|
||||
ERROR 42S02: Unknown table 'test.t2'
|
||||
|
@ -25,7 +25,7 @@ create table t2(a int, constraint a foreign key a (a) references t1(a)) engine=i
|
||||
ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Warning 150 Create table '`test`.`t2`' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near ' foreign key a (a) references t1(a)) engine=innodb'.
|
||||
Warning 150 Create table `test`.`t2` with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near ' foreign key a (a) references t1(a)) engine=innodb'.
|
||||
Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||
Warning 1215 Cannot add foreign key constraint for `t2`
|
||||
drop table t1;
|
||||
@ -42,7 +42,7 @@ alter table t2 add constraint b foreign key (b) references t2(b);
|
||||
ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Warning 150 Alter table '`test`.`t2`' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near ' foreign key (b) references t2(b)'.
|
||||
Warning 150 Alter table `test`.`t2` with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns near ' foreign key (b) references t2(b)'.
|
||||
Error 1005 Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed")
|
||||
Warning 1215 Cannot add foreign key constraint for `t2`
|
||||
drop table t2, t1;
|
||||
|
222
mysql-test/suite/innodb/r/innodb-read-view.result
Normal file
222
mysql-test/suite/innodb/r/innodb-read-view.result
Normal file
@ -0,0 +1,222 @@
|
||||
CREATE TABLE t1 (c1 INT , c2 CHAR(10), PRIMARY KEY (c1)) ENGINE = InnoDB;
|
||||
INSERT INTO t1 VALUES(0, "0");
|
||||
INSERT INTO t1 VALUES(1, "1");
|
||||
INSERT INTO t1 VALUES(2, "2");
|
||||
INSERT INTO t1 VALUES(3, "3");
|
||||
CREATE TABLE t2 (c1 INT , c2 CHAR(10), PRIMARY KEY (c1)) ENGINE = InnoDB;
|
||||
INSERT INTO t2 VALUES(0, "a");
|
||||
INSERT INTO t2 VALUES(1, "b");
|
||||
INSERT INTO t2 VALUES(2, "c");
|
||||
INSERT INTO t2 VALUES(3, "d");
|
||||
connect con1,localhost,root,,;
|
||||
connect con2,localhost,root,,;
|
||||
connection con1;
|
||||
'T1'
|
||||
SET AUTOCOMMIT=0;
|
||||
BEGIN;
|
||||
SELECT * FROM t2;
|
||||
c1 c2
|
||||
0 a
|
||||
1 b
|
||||
2 c
|
||||
3 d
|
||||
connection default;
|
||||
'T2'
|
||||
SET AUTOCOMMIT=0;
|
||||
BEGIN;
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
0 0
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
connection con2;
|
||||
'T3'
|
||||
SET AUTOCOMMIT=0;
|
||||
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
|
||||
BEGIN;
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
0 0
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
SELECT * FROM t2;
|
||||
c1 c2
|
||||
0 a
|
||||
1 b
|
||||
2 c
|
||||
3 d
|
||||
connection con1;
|
||||
'T1'
|
||||
UPDATE t2 SET c1 = c1 + 100;
|
||||
SELECT * FROM t2;
|
||||
c1 c2
|
||||
100 a
|
||||
101 b
|
||||
102 c
|
||||
103 d
|
||||
COMMIT;
|
||||
connection default;
|
||||
'T2'
|
||||
UPDATE t1 SET c1 = c1 + 100;
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
100 0
|
||||
101 1
|
||||
102 2
|
||||
103 3
|
||||
COMMIT;
|
||||
connection con2;
|
||||
'T3'
|
||||
SET DEBUG_SYNC='row_search_for_mysql_before_return WAIT_FOR waiting1';
|
||||
SELECT * FROM t1;;
|
||||
connection default;
|
||||
'T2'
|
||||
SET DEBUG_SYNC='now SIGNAL waiting1';
|
||||
'Signalled T3'
|
||||
connection con2;
|
||||
'T3'
|
||||
c1 c2
|
||||
0 0
|
||||
1 1
|
||||
2 2
|
||||
3 3
|
||||
connection con2;
|
||||
'T3'
|
||||
SET DEBUG_SYNC='row_search_for_mysql_before_return WAIT_FOR waiting1';
|
||||
SELECT * FROM t2;;
|
||||
connection default;
|
||||
'T2'
|
||||
SET DEBUG_SYNC='now SIGNAL waiting1';
|
||||
'Signalled T3'
|
||||
connection con2;
|
||||
'T3'
|
||||
c1 c2
|
||||
0 a
|
||||
1 b
|
||||
2 c
|
||||
3 d
|
||||
connection default;
|
||||
disconnect con1;
|
||||
disconnect con2;
|
||||
connect con1,localhost,root,,;
|
||||
connect con2,localhost,root,,;
|
||||
connection con1;
|
||||
'T1'
|
||||
SET AUTOCOMMIT=0;
|
||||
BEGIN;
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
100 0
|
||||
101 1
|
||||
102 2
|
||||
103 3
|
||||
connection default;
|
||||
'T2'
|
||||
SET AUTOCOMMIT=0;
|
||||
BEGIN;
|
||||
SELECT * FROM t2;
|
||||
c1 c2
|
||||
100 a
|
||||
101 b
|
||||
102 c
|
||||
103 d
|
||||
UPDATE t2 SET c1 = c1 + 100;
|
||||
SELECT * FROM t2;
|
||||
c1 c2
|
||||
200 a
|
||||
201 b
|
||||
202 c
|
||||
203 d
|
||||
COMMIT;
|
||||
connection con2;
|
||||
'T3'
|
||||
SET AUTOCOMMIT=0;
|
||||
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
|
||||
BEGIN;
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
100 0
|
||||
101 1
|
||||
102 2
|
||||
103 3
|
||||
SELECT * FROM t2;
|
||||
c1 c2
|
||||
200 a
|
||||
201 b
|
||||
202 c
|
||||
203 d
|
||||
connection con1;
|
||||
'T1'
|
||||
UPDATE t1 SET c1 = c1 + 100;
|
||||
SELECT * FROM t1;
|
||||
c1 c2
|
||||
200 0
|
||||
201 1
|
||||
202 2
|
||||
203 3
|
||||
COMMIT;
|
||||
connection con2;
|
||||
'T3'
|
||||
SET DEBUG_SYNC='row_select_wait WAIT_FOR waiting1';
|
||||
SELECT * FROM t1;;
|
||||
connection con1;
|
||||
'T2'
|
||||
SET DEBUG_SYNC='now SIGNAL waiting1';
|
||||
'Signalled T3'
|
||||
connection con2;
|
||||
'T3'
|
||||
c1 c2
|
||||
100 0
|
||||
101 1
|
||||
102 2
|
||||
103 3
|
||||
connection con2;
|
||||
'T3'
|
||||
SET DEBUG_SYNC='row_select_wait WAIT_FOR waiting1';
|
||||
SELECT * FROM t2;;
|
||||
connection default;
|
||||
'T2'
|
||||
SET DEBUG_SYNC='now SIGNAL waiting1';
|
||||
'Signalled T3'
|
||||
connection con2;
|
||||
'T3'
|
||||
c1 c2
|
||||
200 a
|
||||
201 b
|
||||
202 c
|
||||
203 d
|
||||
connection default;
|
||||
disconnect con1;
|
||||
disconnect con2;
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
#
|
||||
# Bug 21433768: NON-REPEATABLE READ WITH REPEATABLE READ ISOLATION
|
||||
#
|
||||
connect con1,localhost,root,,;
|
||||
CREATE TABLE t1(col1 INT PRIMARY KEY, col2 INT) ENGINE = InnoDB;
|
||||
INSERT INTO t1 values (1, 0), (2, 0);
|
||||
SELECT * FROM t1 ORDER BY col1;
|
||||
col1 col2
|
||||
1 0
|
||||
2 0
|
||||
START TRANSACTION;
|
||||
UPDATE t1 SET col2 = 100;
|
||||
SET DEBUG_SYNC = 'after_trx_committed_in_memory SIGNAL s1 WAIT_FOR s2';
|
||||
COMMIT;;
|
||||
connection default;
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR s1';
|
||||
UPDATE t1 SET col2 = col2 + 10 where col1 = 1;
|
||||
COMMIT;
|
||||
SELECT * FROM t1 ORDER BY col1;
|
||||
col1 col2
|
||||
1 110
|
||||
2 100
|
||||
SET DEBUG_SYNC = 'now SIGNAL s2';
|
||||
connection con1;
|
||||
disconnect con1;
|
||||
connection default;
|
||||
DROP TABLE t1;
|
||||
SET DEBUG_SYNC= 'RESET';
|
@ -1,3 +1,5 @@
|
||||
SET @save_frequency=@@GLOBAL.innodb_purge_rseg_truncate_frequency;
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
|
||||
SELECT table_id INTO @table_stats_id FROM information_schema.innodb_sys_tables
|
||||
WHERE name = 'mysql/innodb_table_stats';
|
||||
SELECT table_id INTO @index_stats_id FROM information_schema.innodb_sys_tables
|
||||
@ -108,6 +110,7 @@ SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
|
||||
ID FOR_COL_NAME REF_COL_NAME POS
|
||||
test/constraint_test parent_id id 0
|
||||
INSERT INTO parent VALUES(1);
|
||||
InnoDB 0 transactions not purged
|
||||
SELECT name, num_rows, ref_count
|
||||
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
||||
WHERE name LIKE "%parent";
|
||||
@ -169,6 +172,7 @@ INSERT INTO parent VALUES(1, 9);
|
||||
SELECT * FROM parent WHERE id IN (SELECT id FROM parent);
|
||||
id newid
|
||||
1 9
|
||||
InnoDB 0 transactions not purged
|
||||
SELECT name, num_rows, ref_count
|
||||
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
||||
WHERE name LIKE "%parent";
|
||||
@ -176,3 +180,4 @@ name num_rows ref_count
|
||||
test/parent 1 2
|
||||
DROP TABLE child;
|
||||
DROP TABLE parent;
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
|
||||
|
@ -18,9 +18,7 @@ Tables_in_test
|
||||
main
|
||||
ref_table1
|
||||
ref_table2
|
||||
# restart and see if we can still access the main table
|
||||
# restart
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
ALTER TABLE `main` ADD INDEX `idx_1` (`ref_id1`);
|
||||
SHOW CREATE TABLE `main`;
|
||||
Table Create Table
|
||||
|
@ -4,13 +4,17 @@
|
||||
#
|
||||
# Set up the test with a procedure and a function.
|
||||
#
|
||||
SET @saved_frequency= @@GLOBAL.innodb_purge_rseg_truncate_frequency;
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency= 1;
|
||||
CREATE PROCEDURE insert_n(start int, end int)
|
||||
BEGIN
|
||||
DECLARE i INT DEFAULT start;
|
||||
START TRANSACTION;
|
||||
WHILE i <= end do
|
||||
INSERT INTO t1 VALUES (1, 2, 3) ON DUPLICATE KEY UPDATE c = i;
|
||||
SET i = i + 1;
|
||||
END WHILE;
|
||||
COMMIT;
|
||||
END~~
|
||||
CREATE FUNCTION num_pages_get()
|
||||
RETURNS INT
|
||||
@ -47,13 +51,14 @@ connection default;
|
||||
# Connect to default and record how many pages were accessed
|
||||
# when selecting the record using the secondary key.
|
||||
#
|
||||
InnoDB 4 transactions not purged
|
||||
SET @num_pages_1 = num_pages_get();
|
||||
SELECT * FROM t1 force index (b);
|
||||
a b c
|
||||
SET @num_pages_2= num_pages_get();
|
||||
SELECT @num_pages_2 - @num_pages_1 < 500;
|
||||
@num_pages_2 - @num_pages_1 < 500
|
||||
1
|
||||
SELECT IF(@num_pages_2 - @num_pages_1 < 5000, 'OK', @num_pages_2 - @num_pages_1) num_pages_diff;
|
||||
num_pages_diff
|
||||
OK
|
||||
#
|
||||
# Commit and show the final record.
|
||||
#
|
||||
@ -76,6 +81,7 @@ test.t1 check status OK
|
||||
#
|
||||
disconnect con2;
|
||||
disconnect con3;
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;
|
||||
DROP TABLE t1;
|
||||
DROP PROCEDURE insert_n;
|
||||
DROP FUNCTION num_pages_get;
|
||||
|
@ -383,6 +383,17 @@ INSERT INTO t1(id, dept, age, name) VALUES
|
||||
(3996, 'cs4', 20, 'rs2'), (4003, 'cs5', 10, 'rs3'), (4004, 'cs6', 20, 'rs3'),
|
||||
(4011, 'cs7', 10, 'rs4'), (4012, 'cs8', 20, 'rs4'), (4019, 'cs9', 10, 'rs5'),
|
||||
(4020, 'cs10', 20, 'rs5'),(4027, 'cs11', 10, 'rs6'),(4028, 'cs12', 20, 'rs6');
|
||||
set
|
||||
@tmp_uss=@@use_stat_tables,
|
||||
@tmp_occ=@@optimizer_use_condition_selectivity;
|
||||
set
|
||||
use_stat_tables='preferably',
|
||||
optimizer_use_condition_selectivity=4;
|
||||
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;
|
||||
EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref name name 22 const 2 Using where; Using index
|
||||
@ -398,6 +409,9 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5';
|
||||
name dept
|
||||
DROP TABLE t1;
|
||||
set
|
||||
use_stat_tables=@tmp_uss,
|
||||
optimizer_use_condition_selectivity=@tmp_occ;
|
||||
drop table if exists t1;
|
||||
show variables like 'innodb_rollback_on_timeout';
|
||||
Variable_name Value
|
||||
@ -3166,8 +3180,8 @@ SELECT COUNT(*) FROM
|
||||
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
|
||||
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 1537
|
||||
2 DERIVED t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL 1537 Using sort_union(idx,PRIMARY); Using where
|
||||
1 PRIMARY <derived2> ALL NULL NULL NULL NULL #
|
||||
2 DERIVED t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL # Using sort_union(idx,PRIMARY); Using where
|
||||
SELECT COUNT(*) FROM
|
||||
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
|
||||
WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t;
|
||||
|
@ -498,6 +498,29 @@ DELETE FROM t1;
|
||||
COMMIT;
|
||||
InnoDB 0 transactions not purged
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
|
||||
INSERT INTO t1 VALUES (7);
|
||||
ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 0;
|
||||
ALTER TABLE t1 ADD INDEX (c);
|
||||
BEGIN;
|
||||
DELETE FROM t1;
|
||||
INSERT INTO t1 VALUES (4,0),(7,77);
|
||||
COMMIT;
|
||||
BEGIN;
|
||||
DELETE FROM t1 WHERE a=7;
|
||||
UPDATE t1 SET a=7;
|
||||
COMMIT;
|
||||
SELECT * FROM t1 FORCE INDEX(PRIMARY);
|
||||
a c
|
||||
7 0
|
||||
SELECT * FROM t1 FORCE INDEX(c);
|
||||
a c
|
||||
7 0
|
||||
DELETE FROM t1;
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a INT, b INT UNIQUE) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
|
||||
INSERT INTO t1 (a) VALUES (NULL), (NULL);
|
||||
ALTER TABLE t1 DROP a, ADD COLUMN a INT;
|
||||
@ -1326,6 +1349,29 @@ DELETE FROM t1;
|
||||
COMMIT;
|
||||
InnoDB 0 transactions not purged
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=COMPACT;
|
||||
INSERT INTO t1 VALUES (7);
|
||||
ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 0;
|
||||
ALTER TABLE t1 ADD INDEX (c);
|
||||
BEGIN;
|
||||
DELETE FROM t1;
|
||||
INSERT INTO t1 VALUES (4,0),(7,77);
|
||||
COMMIT;
|
||||
BEGIN;
|
||||
DELETE FROM t1 WHERE a=7;
|
||||
UPDATE t1 SET a=7;
|
||||
COMMIT;
|
||||
SELECT * FROM t1 FORCE INDEX(PRIMARY);
|
||||
a c
|
||||
7 0
|
||||
SELECT * FROM t1 FORCE INDEX(c);
|
||||
a c
|
||||
7 0
|
||||
DELETE FROM t1;
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a INT, b INT UNIQUE) ENGINE=InnoDB ROW_FORMAT=COMPACT;
|
||||
INSERT INTO t1 (a) VALUES (NULL), (NULL);
|
||||
ALTER TABLE t1 DROP a, ADD COLUMN a INT;
|
||||
@ -2154,6 +2200,29 @@ DELETE FROM t1;
|
||||
COMMIT;
|
||||
InnoDB 0 transactions not purged
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
|
||||
INSERT INTO t1 VALUES (7);
|
||||
ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 0;
|
||||
ALTER TABLE t1 ADD INDEX (c);
|
||||
BEGIN;
|
||||
DELETE FROM t1;
|
||||
INSERT INTO t1 VALUES (4,0),(7,77);
|
||||
COMMIT;
|
||||
BEGIN;
|
||||
DELETE FROM t1 WHERE a=7;
|
||||
UPDATE t1 SET a=7;
|
||||
COMMIT;
|
||||
SELECT * FROM t1 FORCE INDEX(PRIMARY);
|
||||
a c
|
||||
7 0
|
||||
SELECT * FROM t1 FORCE INDEX(c);
|
||||
a c
|
||||
7 0
|
||||
DELETE FROM t1;
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (a INT, b INT UNIQUE) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
|
||||
INSERT INTO t1 (a) VALUES (NULL), (NULL);
|
||||
ALTER TABLE t1 DROP a, ADD COLUMN a INT;
|
||||
@ -2544,7 +2613,7 @@ SELECT variable_value-@old_instant instants
|
||||
FROM information_schema.global_status
|
||||
WHERE variable_name = 'innodb_instant_alter_column';
|
||||
instants
|
||||
181
|
||||
184
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;
|
||||
#
|
||||
# MDEV-18266: Changing an index comment unnecessarily rebuilds index
|
||||
|
@ -261,3 +261,11 @@ a
|
||||
1
|
||||
3
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-20479: assertion failure in dict_table_get_nth_col() after INSTANT DROP COLUMN
|
||||
#
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
||||
ALTER TABLE t1 ADD COLUMN (b INT, c INT, d INT, e INT NOT NULL DEFAULT 0);
|
||||
ALTER TABLE t1 ADD UNIQUE INDEX(e);
|
||||
ALTER TABLE t1 DROP b, DROP c, DROP d, DROP e;
|
||||
DROP TABLE t1;
|
||||
|
@ -203,3 +203,49 @@ connection default;
|
||||
select * from t2;
|
||||
drop table t2, t1;
|
||||
drop user foo;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-17187 table doesn't exist in engine after ALTER other tables
|
||||
--echo # with CONSTRAINTs
|
||||
--echo #
|
||||
|
||||
set foreign_key_checks=on;
|
||||
create table t1 (id int not null primary key) engine=innodb;
|
||||
create table t2 (id int not null primary key, fid int not null,
|
||||
CONSTRAINT fk_fid FOREIGN KEY (fid) REFERENCES t1 (id))engine=innodb;
|
||||
|
||||
insert into t1 values (1), (2), (3);
|
||||
insert into t2 values (1, 1), (2, 1), (3, 2);
|
||||
|
||||
set foreign_key_checks=off;
|
||||
alter table t2 drop index fk_fid;
|
||||
set foreign_key_checks=on;
|
||||
|
||||
--error ER_ROW_IS_REFERENCED_2
|
||||
delete from t1 where id=2;
|
||||
--error ER_NO_REFERENCED_ROW_2
|
||||
insert into t2 values(4, 99);
|
||||
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
|
||||
set foreign_key_checks=off;
|
||||
delete from t1 where id=2;
|
||||
insert into t2 values(4, 99);
|
||||
set foreign_key_checks=on;
|
||||
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
|
||||
show create table t1;
|
||||
show create table t2;
|
||||
|
||||
# Optional: test DROP TABLE without any prior ha_innobase::open().
|
||||
# This was tested manually, but it would cause --embedded to skip the test,
|
||||
# and the restart would significantly increase the running time.
|
||||
# --source include/restart_mysqld.inc
|
||||
|
||||
--error ER_ROW_IS_REFERENCED_2
|
||||
drop table t1,t2;
|
||||
--error ER_BAD_TABLE_ERROR
|
||||
drop table t1,t2;
|
||||
|
208
mysql-test/suite/innodb/t/innodb-read-view.test
Normal file
208
mysql-test/suite/innodb/t/innodb-read-view.test
Normal file
@ -0,0 +1,208 @@
|
||||
# DEBUG_SYNC must be compiled in.
|
||||
--source include/have_debug_sync.inc
|
||||
--source include/have_debug.inc
|
||||
|
||||
# We need to test the use case:
|
||||
# a. Create a transaction T1 that will be promoted to RW.
|
||||
# b. Create a transaction T2 that will be promoted to RW.
|
||||
# a. Create a RO transaction T3
|
||||
# d. T3 does a select - creates a read view that doesn't include T1 and T2
|
||||
# e. T1 & T2 do some updates - this promotes T1 & T2 to RW transactions
|
||||
# f. T1 & T2 Commit
|
||||
# g. T3 Does a select - it should not see the changes of T1 & T2
|
||||
|
||||
--source include/have_innodb.inc
|
||||
--source include/count_sessions.inc
|
||||
|
||||
CREATE TABLE t1 (c1 INT , c2 CHAR(10), PRIMARY KEY (c1)) ENGINE = InnoDB;
|
||||
INSERT INTO t1 VALUES(0, "0");
|
||||
INSERT INTO t1 VALUES(1, "1");
|
||||
INSERT INTO t1 VALUES(2, "2");
|
||||
INSERT INTO t1 VALUES(3, "3");
|
||||
|
||||
CREATE TABLE t2 (c1 INT , c2 CHAR(10), PRIMARY KEY (c1)) ENGINE = InnoDB;
|
||||
INSERT INTO t2 VALUES(0, "a");
|
||||
INSERT INTO t2 VALUES(1, "b");
|
||||
INSERT INTO t2 VALUES(2, "c");
|
||||
INSERT INTO t2 VALUES(3, "d");
|
||||
|
||||
--connect (con1,localhost,root,,)
|
||||
--connect (con2,localhost,root,,)
|
||||
|
||||
connection con1;
|
||||
--echo 'T1'
|
||||
SET AUTOCOMMIT=0;
|
||||
BEGIN;
|
||||
SELECT * FROM t2;
|
||||
|
||||
connection default;
|
||||
--echo 'T2'
|
||||
SET AUTOCOMMIT=0;
|
||||
BEGIN;
|
||||
SELECT * FROM t1;
|
||||
|
||||
connection con2;
|
||||
--echo 'T3'
|
||||
SET AUTOCOMMIT=0;
|
||||
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
|
||||
BEGIN;
|
||||
SELECT * FROM t1;
|
||||
SELECT * FROM t2;
|
||||
|
||||
connection con1;
|
||||
--echo 'T1'
|
||||
UPDATE t2 SET c1 = c1 + 100;
|
||||
SELECT * FROM t2;
|
||||
COMMIT;
|
||||
|
||||
connection default;
|
||||
--echo 'T2'
|
||||
UPDATE t1 SET c1 = c1 + 100;
|
||||
SELECT * FROM t1;
|
||||
COMMIT;
|
||||
|
||||
connection con2;
|
||||
--echo 'T3'
|
||||
SET DEBUG_SYNC='row_search_for_mysql_before_return WAIT_FOR waiting1';
|
||||
--send SELECT * FROM t1;
|
||||
|
||||
connection default;
|
||||
--echo 'T2'
|
||||
SET DEBUG_SYNC='now SIGNAL waiting1';
|
||||
--echo 'Signalled T3'
|
||||
|
||||
connection con2;
|
||||
--echo 'T3'
|
||||
reap;
|
||||
|
||||
connection con2;
|
||||
--echo 'T3'
|
||||
SET DEBUG_SYNC='row_search_for_mysql_before_return WAIT_FOR waiting1';
|
||||
--send SELECT * FROM t2;
|
||||
|
||||
connection default;
|
||||
--echo 'T2'
|
||||
SET DEBUG_SYNC='now SIGNAL waiting1';
|
||||
--echo 'Signalled T3'
|
||||
|
||||
connection con2;
|
||||
--echo 'T3'
|
||||
reap;
|
||||
|
||||
connection default;
|
||||
disconnect con1;
|
||||
disconnect con2;
|
||||
|
||||
# We need to test the use case:
|
||||
# a. Create a transaction T1 that will be promoted to RW.
|
||||
# b. Create a transaction T2 that will be promoted to RW.
|
||||
# c. T2 does some updates - this promotes T2 to RW transactions
|
||||
# d. T2 Commits
|
||||
# e. Create a RO transaction T3
|
||||
# f. T3 does a select - creates a read view that doesn't include T1
|
||||
# g. T1 does some updates - this promotes T1 to RW transactions
|
||||
# h. T1 Commits
|
||||
# i. T3 Does a select - it should not see the changes made by T1 but should
|
||||
# see the changes by T2
|
||||
|
||||
--connect (con1,localhost,root,,)
|
||||
--connect (con2,localhost,root,,)
|
||||
|
||||
connection con1;
|
||||
--echo 'T1'
|
||||
SET AUTOCOMMIT=0;
|
||||
BEGIN;
|
||||
SELECT * FROM t1;
|
||||
|
||||
connection default;
|
||||
--echo 'T2'
|
||||
SET AUTOCOMMIT=0;
|
||||
BEGIN;
|
||||
SELECT * FROM t2;
|
||||
UPDATE t2 SET c1 = c1 + 100;
|
||||
SELECT * FROM t2;
|
||||
COMMIT;
|
||||
|
||||
connection con2;
|
||||
--echo 'T3'
|
||||
SET AUTOCOMMIT=0;
|
||||
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
|
||||
BEGIN;
|
||||
SELECT * FROM t1;
|
||||
SELECT * FROM t2;
|
||||
|
||||
connection con1;
|
||||
--echo 'T1'
|
||||
UPDATE t1 SET c1 = c1 + 100;
|
||||
SELECT * FROM t1;
|
||||
COMMIT;
|
||||
|
||||
connection con2;
|
||||
--echo 'T3'
|
||||
SET DEBUG_SYNC='row_select_wait WAIT_FOR waiting1';
|
||||
--send SELECT * FROM t1;
|
||||
|
||||
connection con1;
|
||||
--echo 'T2'
|
||||
SET DEBUG_SYNC='now SIGNAL waiting1';
|
||||
--echo 'Signalled T3'
|
||||
|
||||
connection con2;
|
||||
--echo 'T3'
|
||||
reap;
|
||||
|
||||
connection con2;
|
||||
--echo 'T3'
|
||||
SET DEBUG_SYNC='row_select_wait WAIT_FOR waiting1';
|
||||
--send SELECT * FROM t2;
|
||||
|
||||
connection default;
|
||||
--echo 'T2'
|
||||
SET DEBUG_SYNC='now SIGNAL waiting1';
|
||||
--echo 'Signalled T3'
|
||||
|
||||
connection con2;
|
||||
--echo 'T3'
|
||||
reap;
|
||||
|
||||
connection default;
|
||||
disconnect con1;
|
||||
disconnect con2;
|
||||
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
|
||||
--echo #
|
||||
--echo # Bug 21433768: NON-REPEATABLE READ WITH REPEATABLE READ ISOLATION
|
||||
--echo #
|
||||
|
||||
--connect (con1,localhost,root,,)
|
||||
|
||||
CREATE TABLE t1(col1 INT PRIMARY KEY, col2 INT) ENGINE = InnoDB;
|
||||
INSERT INTO t1 values (1, 0), (2, 0);
|
||||
SELECT * FROM t1 ORDER BY col1;
|
||||
|
||||
START TRANSACTION;
|
||||
UPDATE t1 SET col2 = 100;
|
||||
SET DEBUG_SYNC = 'after_trx_committed_in_memory SIGNAL s1 WAIT_FOR s2';
|
||||
--send COMMIT;
|
||||
|
||||
connection default;
|
||||
SET DEBUG_SYNC = 'now WAIT_FOR s1';
|
||||
UPDATE t1 SET col2 = col2 + 10 where col1 = 1;
|
||||
COMMIT;
|
||||
|
||||
SELECT * FROM t1 ORDER BY col1;
|
||||
SET DEBUG_SYNC = 'now SIGNAL s2';
|
||||
|
||||
connection con1;
|
||||
reap;
|
||||
disconnect con1;
|
||||
|
||||
connection default;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
# Clean up resources used in this test case.
|
||||
SET DEBUG_SYNC= 'RESET';
|
||||
--source include/wait_until_count_sessions.inc
|
@ -4,6 +4,8 @@
|
||||
|
||||
--source include/innodb_page_size_small.inc
|
||||
|
||||
SET @save_frequency=@@GLOBAL.innodb_purge_rseg_truncate_frequency;
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
|
||||
LET $MYSQLD_DATADIR = `select @@datadir`;
|
||||
LET $INNODB_PAGE_SIZE = `select @@innodb_page_size`;
|
||||
|
||||
@ -70,6 +72,8 @@ SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS;
|
||||
# INNODB_SYS_TABLESTATS
|
||||
INSERT INTO parent VALUES(1);
|
||||
|
||||
--source include/wait_all_purged.inc
|
||||
|
||||
--sorted_result
|
||||
SELECT name, num_rows, ref_count
|
||||
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
||||
@ -126,6 +130,8 @@ INSERT INTO parent VALUES(1, 9);
|
||||
--sorted_result
|
||||
SELECT * FROM parent WHERE id IN (SELECT id FROM parent);
|
||||
|
||||
--source include/wait_all_purged.inc
|
||||
|
||||
--sorted_result
|
||||
SELECT name, num_rows, ref_count
|
||||
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS
|
||||
@ -134,3 +140,4 @@ WHERE name LIKE "%parent";
|
||||
DROP TABLE child;
|
||||
|
||||
DROP TABLE parent;
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency;
|
||||
|
@ -28,11 +28,8 @@ SET FOREIGN_KEY_CHECKS=0;
|
||||
DROP INDEX `idx_1` ON `main`;
|
||||
SHOW TABLES;
|
||||
|
||||
--echo # restart and see if we can still access the main table
|
||||
--source include/restart_mysqld.inc
|
||||
|
||||
# This is required to access the table
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
ALTER TABLE `main` ADD INDEX `idx_1` (`ref_id1`);
|
||||
SHOW CREATE TABLE `main`;
|
||||
|
||||
|
@ -6,15 +6,19 @@
|
||||
--echo #
|
||||
|
||||
--source include/have_innodb.inc
|
||||
SET @saved_frequency= @@GLOBAL.innodb_purge_rseg_truncate_frequency;
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency= 1;
|
||||
|
||||
DELIMITER ~~;
|
||||
CREATE PROCEDURE insert_n(start int, end int)
|
||||
BEGIN
|
||||
DECLARE i INT DEFAULT start;
|
||||
START TRANSACTION;
|
||||
WHILE i <= end do
|
||||
INSERT INTO t1 VALUES (1, 2, 3) ON DUPLICATE KEY UPDATE c = i;
|
||||
SET i = i + 1;
|
||||
END WHILE;
|
||||
COMMIT;
|
||||
END~~
|
||||
|
||||
CREATE FUNCTION num_pages_get()
|
||||
@ -60,11 +64,13 @@ connection default;
|
||||
--echo # Connect to default and record how many pages were accessed
|
||||
--echo # when selecting the record using the secondary key.
|
||||
--echo #
|
||||
--let $wait_all_purged=4
|
||||
--source include/wait_all_purged.inc
|
||||
SET @num_pages_1 = num_pages_get();
|
||||
SELECT * FROM t1 force index (b);
|
||||
SET @num_pages_2= num_pages_get();
|
||||
|
||||
SELECT @num_pages_2 - @num_pages_1 < 500;
|
||||
SELECT IF(@num_pages_2 - @num_pages_1 < 5000, 'OK', @num_pages_2 - @num_pages_1) num_pages_diff;
|
||||
|
||||
--echo #
|
||||
--echo # Commit and show the final record.
|
||||
@ -81,6 +87,7 @@ CHECK TABLE t1;
|
||||
--echo #
|
||||
disconnect con2;
|
||||
disconnect con3;
|
||||
SET GLOBAL innodb_purge_rseg_truncate_frequency= @saved_frequency;
|
||||
DROP TABLE t1;
|
||||
DROP PROCEDURE insert_n;
|
||||
DROP FUNCTION num_pages_get;
|
||||
|
@ -850,6 +850,7 @@ set @optimizer_switch_saved=@@optimizer_switch;
|
||||
SET SESSION optimizer_switch='derived_merge=off';
|
||||
SET SESSION sort_buffer_size = 1024*36;
|
||||
|
||||
--replace_column 9 #
|
||||
EXPLAIN
|
||||
SELECT COUNT(*) FROM
|
||||
(SELECT * FROM t1 FORCE INDEX (idx,PRIMARY)
|
||||
|
@ -365,6 +365,30 @@ COMMIT;
|
||||
--source include/wait_all_purged.inc
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# MDEV-20066 Wrong value on instantly added column after DELETE and UPDATE
|
||||
#
|
||||
|
||||
eval CREATE TABLE t1(a INT PRIMARY KEY) $engine;
|
||||
INSERT INTO t1 VALUES (7);
|
||||
|
||||
ALTER TABLE t1 ADD COLUMN c INT NOT NULL DEFAULT 0;
|
||||
ALTER TABLE t1 ADD INDEX (c);
|
||||
|
||||
BEGIN;
|
||||
DELETE FROM t1;
|
||||
INSERT INTO t1 VALUES (4,0),(7,77);
|
||||
COMMIT;
|
||||
BEGIN;
|
||||
DELETE FROM t1 WHERE a=7;
|
||||
UPDATE t1 SET a=7;
|
||||
COMMIT;
|
||||
SELECT * FROM t1 FORCE INDEX(PRIMARY);
|
||||
SELECT * FROM t1 FORCE INDEX(c);
|
||||
DELETE FROM t1;
|
||||
CHECK TABLE t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
# MDEV-15562 Instant DROP/ADD/reorder columns
|
||||
|
||||
eval CREATE TABLE t1 (a INT, b INT UNIQUE) $engine;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user