Merge 10.1 into 10.2

This commit is contained in:
Marko Mäkelä 2018-08-02 08:19:57 +03:00
commit ef3070e997
172 changed files with 3937 additions and 1012 deletions

View file

@ -176,6 +176,12 @@ IF(UNIX)
ENDIF()
OPTION (WITH_UNIT_TESTS "Compile MySQL with unit tests" ON)
IF (WITHOUT_SERVER)
SET (SKIP_COMPONENTS "Server|IniFiles|SuportFiles|Readme")
ELSE()
SET (SKIP_COMPONENTS "N-O-N-E")
ENDIF()
OPTION(NOT_FOR_DISTRIBUTION "Allow linking with GPLv2-incompatible system libraries. Only set it you never plan to distribute the resulting binaries" OFF)
INCLUDE(check_compiler_flag)

View file

@ -79,7 +79,7 @@ ulong bytes_sent = 0L, bytes_received = 0L;
ulong mysqld_net_retry_count = 10L;
ulong open_files_limit;
ulong opt_binlog_rows_event_max_size;
uint test_flags = 0;
ulonglong test_flags = 0;
static uint opt_protocol= 0;
static FILE *result_file;
static char *result_file_name= 0;

View file

@ -46,6 +46,10 @@ MACRO(CHECK_DTRACE)
AND NOT CMAKE_SYSTEM_NAME MATCHES "SunOS")
SET(ENABLE_DTRACE ON CACHE BOOL "Enable dtrace")
ENDIF()
# On GNU/Hurd, dtrace is not supported
IF(DTRACE AND CMAKE_SYSTEM_NAME MATCHES "GNU")
SET(ENABLE_DTRACE OFF CACHE BOOL "Disable dtrace")
ENDIF()
SET(HAVE_DTRACE ${ENABLE_DTRACE})
IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
IF(CMAKE_SIZEOF_VOID_P EQUAL 4)

View file

@ -115,7 +115,12 @@ FUNCTION(INSTALL_SCRIPT)
SET(COMP)
ENDIF()
IF (COMP MATCHES ${SKIP_COMPONENTS})
RETURN()
ENDIF()
INSTALL(PROGRAMS ${script} DESTINATION ${ARG_DESTINATION} ${COMP})
INSTALL_MANPAGE(${script})
ENDFUNCTION()
@ -132,6 +137,10 @@ FUNCTION(INSTALL_DOCUMENTATION)
SET(destination ${INSTALL_DOCDIR})
ENDIF()
IF (ARG_COMPONENT MATCHES ${SKIP_COMPONENTS})
RETURN()
ENDIF()
STRING(TOUPPER ${ARG_COMPONENT} COMPUP)
IF(CPACK_COMPONENT_${COMPUP}_GROUP)
SET(group ${CPACK_COMPONENT_${COMPUP}_GROUP})

View file

@ -75,6 +75,9 @@ FUNCTION (MYSQL_ADD_EXECUTABLE)
ELSE()
SET(COMP COMPONENT Client)
ENDIF()
IF (COMP MATCHES ${SKIP_COMPONENTS})
RETURN()
ENDIF()
MYSQL_INSTALL_TARGETS(${target} DESTINATION ${ARG_DESTINATION} ${COMP})
ENDIF()
ENDFUNCTION()

View file

@ -77,6 +77,9 @@ IF(NOT VERSION)
SET(DEFAULT_MACHINE "i386")
ENDIF()
ENDIF()
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "GNU")
SET(DEFAULT_PLATFORM "GNU")
SET(DEFAULT_MACHINE "i386")
ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
IF(CMAKE_OSX_DEPLOYMENT_TARGET)
SET(DEFAULT_PLATFORM "osx${CMAKE_OSX_DEPLOYMENT_TARGET}")

View file

@ -631,11 +631,14 @@ static
int
mkdirp(const char *pathname, int Flags, myf MyFlags)
{
char parent[PATH_MAX], *p;
char *parent, *p;
int len = strlen(pathname) + 1;
/* make a parent directory path */
strncpy(parent, pathname, sizeof(parent));
parent[sizeof(parent) - 1] = 0;
if (!(parent= (char *)malloc(len)))
return(-1);
strncpy(parent, pathname, len);
parent[len-1]= 0;
for (p = parent + strlen(parent);
!is_path_separator(*p) && p != parent; p--);
@ -644,19 +647,23 @@ mkdirp(const char *pathname, int Flags, myf MyFlags)
/* try to make parent directory */
if (p != parent && mkdirp(parent, Flags, MyFlags) != 0) {
free(parent);
return(-1);
}
/* make this one if parent has been made */
if (my_mkdir(pathname, Flags, MyFlags) == 0) {
free(parent);
return(0);
}
/* if it already exists that is fine */
if (errno == EEXIST) {
free(parent);
return(0);
}
free(parent);
return(-1);
}
@ -666,17 +673,24 @@ bool
equal_paths(const char *first, const char *second)
{
#ifdef HAVE_REALPATH
char real_first[PATH_MAX];
char real_second[PATH_MAX];
char *real_first, *real_second;
int result;
if (realpath(first, real_first) == NULL) {
return false;
}
if (realpath(second, real_second) == NULL) {
real_first = realpath(first, 0);
if (real_first == NULL) {
return false;
}
return (strcmp(real_first, real_second) == 0);
real_second = realpath(second, 0);
if (real_second == NULL) {
free(real_first);
return false;
}
result = strcmp(real_first, real_second);
free(real_first);
free(real_second);
return result == 0;
#else
return strcmp(first, second) == 0;
#endif

View file

@ -371,7 +371,7 @@ typedef int (*my_charset_conv_mb_wc)(CHARSET_INFO *, my_wc_t *,
typedef int (*my_charset_conv_wc_mb)(CHARSET_INFO *, my_wc_t,
uchar *, uchar *);
typedef size_t (*my_charset_conv_case)(CHARSET_INFO *,
char *, size_t, char *, size_t);
const char *, size_t, char *, size_t);
/*
A structure to return the statistics of a native string copying,
@ -726,9 +726,11 @@ size_t my_copy_fix_mb(CHARSET_INFO *cs,
/* Functions for 8bit */
extern size_t my_caseup_str_8bit(CHARSET_INFO *, char *);
extern size_t my_casedn_str_8bit(CHARSET_INFO *, char *);
extern size_t my_caseup_8bit(CHARSET_INFO *, char *src, size_t srclen,
extern size_t my_caseup_8bit(CHARSET_INFO *,
const char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_casedn_8bit(CHARSET_INFO *, char *src, size_t srclen,
extern size_t my_casedn_8bit(CHARSET_INFO *,
const char *src, size_t srclen,
char *dst, size_t dstlen);
extern int my_strcasecmp_8bit(CHARSET_INFO * cs, const char *, const char *);
@ -822,17 +824,17 @@ int my_charlen_8bit(CHARSET_INFO *, const uchar *str, const uchar *end);
/* Functions for multibyte charsets */
extern size_t my_caseup_str_mb(CHARSET_INFO *, char *);
extern size_t my_casedn_str_mb(CHARSET_INFO *, char *);
extern size_t my_caseup_mb(CHARSET_INFO *, char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_casedn_mb(CHARSET_INFO *, char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_caseup_mb_varlen(CHARSET_INFO *, char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_casedn_mb_varlen(CHARSET_INFO *, char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_caseup_ujis(CHARSET_INFO *, char *src, size_t srclen,
extern size_t my_caseup_mb(CHARSET_INFO *,
const char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_casedn_mb(CHARSET_INFO *,
const char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_caseup_ujis(CHARSET_INFO *,
const char *src, size_t srclen,
char *dst, size_t dstlen);
extern size_t my_casedn_ujis(CHARSET_INFO *, char *src, size_t srclen,
extern size_t my_casedn_ujis(CHARSET_INFO *,
const char *src, size_t srclen,
char *dst, size_t dstlen);
extern int my_strcasecmp_mb(CHARSET_INFO * cs,const char *, const char *);

View file

@ -1,7 +1,7 @@
#ifndef SQL_COMMON_INCLUDED
#define SQL_COMMON_INCLUDED
/* Copyright (c) 2003, 2012, Oracle and/or its affiliates.
Copyright (c) 2010, 2012, Monty Program Ab
/* Copyright (c) 2003, 2018, Oracle and/or its affiliates.
Copyright (c) 2010, 2018, 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

View file

@ -0,0 +1,15 @@
--echo #
--echo # MDEV-13118 Wrong results with LOWER and UPPER and subquery
--echo #
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
--sorted_result
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
--sorted_result
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;

View file

@ -3048,6 +3048,29 @@ DROP TABLE t1;
SELECT _binary 0x7E, _binary X'7E', _binary B'01111110';
_binary 0x7E _binary X'7E' _binary B'01111110'
~ ~ ~
SET NAMES utf8, character_set_connection=binary;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varbinary(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
abcdefghi-abcdefghi
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View file

@ -33844,6 +33844,29 @@ HEX(a) CHAR_LENGTH(a)
DROP TABLE t1;
SELECT _eucjpms 0x8EA0;
ERROR HY000: Invalid eucjpms character string: '8EA0'
SET NAMES eucjpms;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET eucjpms DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View file

@ -25405,6 +25405,35 @@ A1A1A1A1A1A120202020202020202020202020202020202020
# End of 5.6 tests
#
#
# Start of 10.0 tests
#
SET NAMES utf8, character_set_connection=euckr;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET euckr DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#
#
# Start of 10.2 tests
#
#

View file

@ -5077,6 +5077,29 @@ E05C5B
E05B
DROP TABLE t1;
# Start of ctype_E05C.inc
SET NAMES utf8, character_set_connection=gbk;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET gbk DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# MDEV-9886 Illegal mix of collations with a view comparing a field to a binary constant
#

View file

@ -8022,6 +8022,29 @@ a
0
DROP VIEW v1;
DROP TABLE t1;
SET NAMES latin1;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View file

@ -5685,6 +5685,29 @@ c2
YWJjZGVmZ2hp-YWJjZGVmZ2hp
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
SET NAMES utf8, character_set_connection=ucs2;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET ucs2 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View file

@ -26149,6 +26149,29 @@ HEX(a) CHAR_LENGTH(a)
DROP TABLE t1;
SELECT _ujis 0x8EA0;
ERROR HY000: Invalid ujis character string: '8EA0'
SET NAMES ujis;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET ujis DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View file

@ -2142,6 +2142,29 @@ EXECUTE stmt USING @arg00;
CONCAT(_utf16'a' COLLATE utf16_unicode_ci, ?)
aÿ
DEALLOCATE PREPARE stmt;
SET NAMES utf8, character_set_connection=utf16;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET utf16 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View file

@ -2326,6 +2326,35 @@ DFFFFFDFFFFF9CFFFF9DFFFF9EFFFF
# End of 5.6 tests
#
#
# Start of 10.0 tests
#
SET NAMES utf8, character_set_connection=utf16le;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET utf16le DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# Start of 10.0 tests
#
#
# Start of 10.1 tests
#
#

View file

@ -2241,6 +2241,29 @@ EXECUTE stmt USING @arg00;
CONCAT(_utf32'a' COLLATE utf32_unicode_ci, ?)
aÿ
DEALLOCATE PREPARE stmt;
SET NAMEs utf8, character_set_connection=utf32;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET utf32 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View file

@ -10286,6 +10286,29 @@ SELECT * FROM v1;
c
ß
DROP VIEW v1;
SET NAMES utf8;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View file

@ -3478,6 +3478,29 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
SET NAMES default;
SET NAMES utf8mb4;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET @save_optimizer_switch=@@optimizer_switch;
SET optimizer_switch=_latin1'derived_merge=on';
CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
c2
abcdefghi-abcdefghi
abcdefghi-abcdefghi
SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
c2
ABCDEFGHI-ABCDEFGHI
ABCDEFGHI-ABCDEFGHI
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#

View file

@ -1053,6 +1053,7 @@ INSERT INTO t2 VALUES (NULL),(NULL);
CREATE TABLE t3 (c VARCHAR(1024) CHARACTER SET utf8, d INT) ENGINE=MyISAM;
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3;
INSERT INTO t3 VALUES ('abc',NULL),('def',4);
set @save_join_cache_level= @@join_cache_level;
SET join_cache_level= 8;
explain
SELECT * FROM v1, t2, v3 WHERE a = c AND b = d;
@ -1082,6 +1083,38 @@ i
drop procedure pr;
drop view v1;
drop table t1;
set @@join_cache_level= @save_join_cache_level;
#
# MDEV-16307: Incorrect results when using BNLH join instead of BNL join with views
#
CREATE TABLE t1 (c1 text, c2 int);
INSERT INTO t1 VALUES ('a',1), ('c',3), ('g',7), ('d',4), ('c',3);
CREATE TABLE t2 (c1 text, c2 int);
INSERT INTO t2 VALUES ('b',2), ('c',3);
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
explain SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
2 DERIVED t1 ALL NULL NULL NULL NULL 5
SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
c1 c2 c1 c2
c 3 c 3
c 3 c 3
set @save_join_cache_level= @@join_cache_level;
set @@join_cache_level=4;
explain SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
1 PRIMARY <derived2> hash_ALL NULL #hash#$hj 3 test.t2.c1 5 Using where; Using join buffer (flat, BNLH join)
2 DERIVED t1 ALL NULL NULL NULL NULL 5
SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
c1 c2 c1 c2
c 3 c 3
c 3 c 3
drop table t1,t2;
drop view v1;
set @@join_cache_level= @save_join_cache_level;
# end of 5.5
#
# Start of 10.1 tests

View file

@ -1753,6 +1753,7 @@ drop user mysqltest@localhost;
disconnect user1;
drop database mysqltest;
use test;
call mtr.add_suppression("Can't open and lock privilege tables");
FLUSH PRIVILEGES without procs_priv table.
RENAME TABLE mysql.procs_priv TO mysql.procs_gone;
FLUSH PRIVILEGES;
@ -1846,8 +1847,6 @@ BEGIN
SET @x = 0;
REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;
END ;||
Warnings:
Warning 1404 Failed to grant EXECUTE and ALTER ROUTINE privileges
connection default;
SHOW GRANTS FOR 'user1'@'localhost';
Grants for user1@localhost
@ -1858,6 +1857,7 @@ SHOW GRANTS FOR 'user2';
Grants for user2@%
GRANT USAGE ON *.* TO 'user2'@'%'
GRANT CREATE, CREATE ROUTINE ON `db1`.* TO 'user2'@'%'
GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `db1`.`proc2` TO 'user2'@'%'
disconnect con1;
disconnect con2;
DROP PROCEDURE db1.proc1;

View file

@ -1505,6 +1505,46 @@ DROP VIEW v2;
DROP TABLE t1,t2;
SET optimizer_switch=@save_optimizer_switch;
#
# MDEV-16512
# Server crashes in find_field_in_table_ref on 2nd execution of SP referring to
# non-existing field
#
CREATE TABLE t (i INT);
CREATE PROCEDURE p() SELECT t1.f FROM t AS t1 JOIN t AS t2 USING (f);
CALL p;
ERROR 42S22: Unknown column 'f' in 'from clause'
CALL p;
ERROR 42S22: Unknown column 'f' in 'from clause'
FLUSH TABLES;
CALL p;
ERROR 42S22: Unknown column 'f' in 'from clause'
DROP TABLE t;
CREATE TABLE t (f INT);
CALL p;
ERROR 42S22: Unknown column 'f' in 'from clause'
DROP TABLE t;
CREATE TABLE t (i INT);
CALL p;
ERROR 42S22: Unknown column 'f' in 'from clause'
DROP PROCEDURE p;
DROP TABLE t;
CREATE TABLE t1 (a INT, b INT);
CREATE TABLE t2 (a INT);
CREATE TABLE t3 (a INT, c INT);
CREATE TABLE t4 (a INT, c INT);
CREATE TABLE t5 (a INT, c INT);
CREATE PROCEDURE p1() SELECT c FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a)
LEFT JOIN t5 USING (a)) USING (a);
CALL p1;
ERROR 23000: Column 'c' in field list is ambiguous
CALL p1;
ERROR 23000: Column 'c' in field list is ambiguous
DROP PROCEDURE p1;
DROP TABLE t1,t2,t3,t4,t5;
#
# End of MariaDB 5.5 tests
#
#
# Bug #35268: Parser can't handle STRAIGHT_JOIN with USING
#
CREATE TABLE t1 (a int);

View file

@ -5925,6 +5925,39 @@ SET join_buffer_space_limit= default;
set optimizer_switch=@save_optimizer_switch;
DROP TABLE t1,t4,t5,t2;
#
# MDEV-16603: BNLH for query with materialized semi-join
#
set join_cache_level=4;
CREATE TABLE t1 ( i1 int, v1 varchar(1)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (7,'x');
CREATE TABLE t2 (i1 int, v1 varchar(1), KEY v1 (v1,i1)) ENGINE=InnoDB;
INSERT INTO t2 VALUES
(NULL,'x'),(1,'x'),(3,'x'),(5,'x'),(8,'x'),(48,'x'),
(228,'x'),(3,'y'),(1,'z'),(9,'z');
CREATE TABLE temp
SELECT t1.i1 AS f1, t1.v1 AS f2 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1));
SELECT * FROM temp
WHERE (f1,f2) IN (SELECT t1.i1, t1.v1 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1)));
f1 f2
7 x
7 x
7 x
7 x
7 x
7 x
7 x
EXPLAIN EXTENDED SELECT * FROM temp
WHERE (f1,f2) IN (SELECT t1.i1, t1.v1 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1)));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 1 100.00
1 PRIMARY temp hash_ALL NULL #hash#$hj 9 test.t1.i1,test.t1.v1 7 100.00 Using where; Using join buffer (flat, BNLH join)
2 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00 Using where
2 MATERIALIZED t2 hash_index v1 #hash#v1:v1 4:9 test.t1.v1 10 10.00 Using index; Using join buffer (flat, BNLH join)
Warnings:
Note 1003 select `test`.`temp`.`f1` AS `f1`,`test`.`temp`.`f2` AS `f2` from `test`.`temp` semi join (`test`.`t2` join `test`.`t1`) where `test`.`temp`.`f1` = `test`.`t1`.`i1` and `test`.`t2`.`v1` = `test`.`t1`.`v1` and `test`.`temp`.`f2` = `test`.`t1`.`v1`
DROP TABLE t1,t2,temp;
SET join_cache_level = default;
#
# MDEV-5123 Remove duplicated conditions pushed both to join_tab->select_cond and join_tab->cache_select->cond for blocked joins.
#
set join_cache_level=default;

View file

@ -2460,5 +2460,55 @@ id sid id
1 NULL NULL
2 NULL NULL
drop table t1, t2;
#
# MDEV-16726: SELECT with STRAGHT JOIN containing NESTED RIGHT JOIN
# converted to INNER JOIN with first constant inner table
#
CREATE TABLE t1 (
pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1), KEY v1 (v1,i1)
) engine=MyISAM;
INSERT INTO t1 VALUES
(8,3,'c','c'),(9,4,'z','z'),(10,3,'i','i'),(11,186,'x','x'),
(14,226,'m','m'),(15,133,'p','p');
CREATE TABLE t2 (
pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1)
) engine=MyISAM;
INSERT INTO t2 VALUES (10,6,'p','p');
EXPLAIN EXTENDED
SELECT STRAIGHT_JOIN t2.v2
FROM
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
RIGHT JOIN
(t2,t1)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1003 select straight_join 'p' AS `v2` from `test`.`t1` join `test`.`t1` `tb1` left join `test`.`t1` `tb2` on(multiple equal(`test`.`tb2`.`v1`, NULL)) where 0 order by NULL
EXPLAIN EXTENDED
SELECT STRAIGHT_JOIN t2.v2
FROM
(t2,t1)
LEFT JOIN
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1003 select straight_join 'p' AS `v2` from `test`.`t1` join `test`.`t1` `tb1` left join `test`.`t1` `tb2` on(multiple equal(`test`.`tb2`.`v1`, NULL)) where 0 order by NULL
SELECT STRAIGHT_JOIN DISTINCT t2.v2
FROM
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
RIGHT JOIN
(t2,t1)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
v2
DROP TABLE t1,t2;
# end of 5.5 tests
SET optimizer_switch=@save_optimizer_switch;

View file

@ -2471,6 +2471,56 @@ id sid id
1 NULL NULL
2 NULL NULL
drop table t1, t2;
#
# MDEV-16726: SELECT with STRAGHT JOIN containing NESTED RIGHT JOIN
# converted to INNER JOIN with first constant inner table
#
CREATE TABLE t1 (
pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1), KEY v1 (v1,i1)
) engine=MyISAM;
INSERT INTO t1 VALUES
(8,3,'c','c'),(9,4,'z','z'),(10,3,'i','i'),(11,186,'x','x'),
(14,226,'m','m'),(15,133,'p','p');
CREATE TABLE t2 (
pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1)
) engine=MyISAM;
INSERT INTO t2 VALUES (10,6,'p','p');
EXPLAIN EXTENDED
SELECT STRAIGHT_JOIN t2.v2
FROM
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
RIGHT JOIN
(t2,t1)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1003 select straight_join 'p' AS `v2` from `test`.`t1` join `test`.`t1` `tb1` left join `test`.`t1` `tb2` on(multiple equal(`test`.`tb2`.`v1`, NULL)) where 0 order by NULL
EXPLAIN EXTENDED
SELECT STRAIGHT_JOIN t2.v2
FROM
(t2,t1)
LEFT JOIN
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1003 select straight_join 'p' AS `v2` from `test`.`t1` join `test`.`t1` `tb1` left join `test`.`t1` `tb2` on(multiple equal(`test`.`tb2`.`v1`, NULL)) where 0 order by NULL
SELECT STRAIGHT_JOIN DISTINCT t2.v2
FROM
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
RIGHT JOIN
(t2,t1)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
v2
DROP TABLE t1,t2;
# end of 5.5 tests
SET optimizer_switch=@save_optimizer_switch;
set join_cache_level=default;

View file

@ -144,3 +144,7 @@ select * from t2;
a
1
drop table tmp,t2;
create table t1 (a int) engine=memory;
rename table t1 to non_existent.t2;
ERROR 42000: Unknown database 'non_existent'
drop table t1;

View file

@ -228,8 +228,6 @@ FLUSH PRIVILEGES;
connect con1, localhost, mysqltest_1,,;
connection con1;
CREATE PROCEDURE p1(i INT) BEGIN END;
Warnings:
Warning 1404 Failed to grant EXECUTE and ALTER ROUTINE privileges
disconnect con1;
connection default;
DROP PROCEDURE p1;

View file

@ -516,4 +516,133 @@ use test;
drop database db1;
drop database db2;
drop table t1;
#
# MDEV-16552: [10.0] ASAN global-buffer-overflow in is_stat_table / statistics_for_tables_is_needed
#
SET use_stat_tables = PREFERABLY;
SELECT CONVERT_TZ( '1991-09-20 10:11:02', '+00:00', 'GMT' );
CONVERT_TZ( '1991-09-20 10:11:02', '+00:00', 'GMT' )
NULL
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16757: manual addition of min/max statistics for BLOB
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze Warning Engine-independent statistics are not collected for column 't'
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
DELETE FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='t';
INSERT INTO mysql.column_stats VALUES
('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 t bar foo 0.0000 3.0000 1.0000 0 NULL NULL
SELECT pk FROM t1;
pk
1
2
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16760: CREATE OR REPLACE TABLE after ANALYZE TABLE
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk int PRIMARY KEY, c varchar(32));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT * FROM t1;
pk c
1 foo
2 bar
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 c bar foo 0.0000 3.0000 1.0000 0 NULL NULL
CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
SELECT * FROM t1;
pk a
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16757: manual addition of min/max statistics for BLOB
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze Warning Engine-independent statistics are not collected for column 't'
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
DELETE FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='t';
INSERT INTO mysql.column_stats VALUES
('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 t bar foo 0.0000 3.0000 1.0000 0 NULL NULL
SELECT pk FROM t1;
pk
1
2
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16760: CREATE OR REPLACE TABLE after ANALYZE TABLE
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk int PRIMARY KEY, c varchar(32));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT * FROM t1;
pk c
1 foo
2 bar
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 c bar foo 0.0000 3.0000 1.0000 0 NULL NULL
CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
SELECT * FROM t1;
pk a
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16711:CREATE OR REPLACE TABLE introducing BLOB column
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t CHAR(60));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
SELECT MAX(pk) FROM t1;
MAX(pk)
NULL
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;

View file

@ -543,6 +543,135 @@ use test;
drop database db1;
drop database db2;
drop table t1;
#
# MDEV-16552: [10.0] ASAN global-buffer-overflow in is_stat_table / statistics_for_tables_is_needed
#
SET use_stat_tables = PREFERABLY;
SELECT CONVERT_TZ( '1991-09-20 10:11:02', '+00:00', 'GMT' );
CONVERT_TZ( '1991-09-20 10:11:02', '+00:00', 'GMT' )
NULL
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16757: manual addition of min/max statistics for BLOB
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze Warning Engine-independent statistics are not collected for column 't'
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
DELETE FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='t';
INSERT INTO mysql.column_stats VALUES
('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 t bar foo 0.0000 3.0000 1.0000 0 NULL NULL
SELECT pk FROM t1;
pk
1
2
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16760: CREATE OR REPLACE TABLE after ANALYZE TABLE
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk int PRIMARY KEY, c varchar(32));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT * FROM t1;
pk c
1 foo
2 bar
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 c bar foo 0.0000 3.0000 1.0000 0 NULL NULL
CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
SELECT * FROM t1;
pk a
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16757: manual addition of min/max statistics for BLOB
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze Warning Engine-independent statistics are not collected for column 't'
test.t1 analyze status OK
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
DELETE FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='t';
INSERT INTO mysql.column_stats VALUES
('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 t bar foo 0.0000 3.0000 1.0000 0 NULL NULL
SELECT pk FROM t1;
pk
1
2
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16760: CREATE OR REPLACE TABLE after ANALYZE TABLE
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk int PRIMARY KEY, c varchar(32));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
SELECT * FROM t1;
pk c
1 foo
2 bar
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
test t1 c bar foo 0.0000 3.0000 1.0000 0 NULL NULL
CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
SELECT * FROM t1;
pk a
SELECT * FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
#
# MDEV-16711:CREATE OR REPLACE TABLE introducing BLOB column
#
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t CHAR(60));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
SELECT MAX(pk) FROM t1;
MAX(pk)
NULL
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
set optimizer_switch=@save_optimizer_switch_for_stat_tables_test;
SET SESSION STORAGE_ENGINE=DEFAULT;

View file

@ -2391,6 +2391,99 @@ ec70316637232000158bbfc8bcbe5d60
ebb4620037332000158bbfc8bcbe5d89
DROP TABLE t1,t2,t3;
set optimizer_switch=@save_optimizer_switch;
#
# MDEV-16751: Server crashes in st_join_table::cleanup or
# TABLE_LIST::is_with_table_recursive_reference with join_cache_level>2
#
set @save_join_cache_level= @@join_cache_level;
set join_cache_level=4;
CREATE TABLE t1 ( id int NOT NULL);
INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL) ;
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)
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
1
1
1
set @@join_cache_level= @save_join_cache_level;
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
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
1
1
1
drop table t1,t2;
#
# MDEV-15454: Nested SELECT IN returns wrong results
#
CREATE TABLE t1 ( a int NOT NULL PRIMARY KEY);
CREATE TABLE t2 ( a int, b int );
INSERT INTO t2 VALUES (7878, 96),(3465, 96),(1403, 96),(4189, 96),(8732, 96), (5,96);
CREATE TABLE t3 (c int unsigned NOT NULL, b int unsigned NOT NULL, PRIMARY KEY (c,b));
INSERT INTO t3 (c, b) VALUES (27, 96);
CREATE PROCEDURE prepare_data()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE i < 1000 DO
INSERT INTO t1 (a) VALUES (i);
INSERT INTO t2 (a,b) VALUES (i,56);
INSERT INTO t3 (c,b) VALUES (i,i);
SET i = i + 1;
END WHILE;
END$$
CALL prepare_data();
SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27);
a
7878
3465
1403
4189
8732
5
set @save_optimizer_switch= @@optimizer_switch;
SET optimizer_switch='materialization=off';
SELECT t1.a FROM t1
WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
a
5
SET optimizer_switch='materialization=on';
SELECT t1.a FROM t1
WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
a
5
drop procedure prepare_data;
set @@optimizer_switch= @save_optimizer_switch;
drop table t1,t2,t3;
CREATE TABLE t1 ( id int NOT NULL, key(id));
INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL);
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
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
1
1
1
drop table t1,t2;
drop view v1;
# End of 5.5 tests
#
# MDEV-7220: Materialization strategy is not used for REPLACE ... SELECT

View file

@ -442,7 +442,7 @@ SELECT i2 FROM t2 RIGHT JOIN t3 ON (c3 = c2) WHERE pk3 = i1
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY t3 const PRIMARY PRIMARY 4 const 1
2 DEPENDENT SUBQUERY t2 index NULL i2 11 NULL 2 Using where; Using index
2 DEPENDENT SUBQUERY t2 index i2 i2 11 NULL 2 Using where; Using index
DROP TABLE t1,t2,t3;
#
# MDEV-7599: in-to-exists chosen after min/max optimization

View file

@ -1728,6 +1728,57 @@ id
13
drop table t1;
#
# MDEV-15982: Incorrect results when subquery is materialized
#
CREATE TABLE `t1` (`id` int(32) NOT NULL primary key);
INSERT INTO `t1` VALUES
(45), (46), (47), (48), (49), (50), (51), (52), (53), (54), (55), (56), (57), (58), (59), (60), (61), (62),
(63), (64), (65), (66), (67), (68), (69), (70), (71), (72), (73), (74), (75), (76), (77), (78), (79), (80),
(81), (82), (83), (84), (85), (86), (87), (88), (89), (90), (91), (92),(93),(94),(95),(96), (97), (98),
(99), (100), (101), (102), (103), (104), (105), (106), (107), (108), (109), (110), (111), (112), (113),
(114), (115), (116), (117), (118), (119), (120), (121), (122), (123), (124), (125), (126), (127), (128),
(129), (130), (131), (132), (133), (134), (135), (136), (137), (138), (139), (140), (141), (142), (143), (144), (145), (146),
(147), (148), (149), (150), (151), (152), (153), (154), (155), (156), (157), (158), (159), (160), (161),
(162), (163), (164), (165), (166), (167), (168), (169), (170), (171), (172), (173),
(174), (175), (176), (177), (178), (179), (180), (181), (182), (183), (2), (3), (4), (5), (6), (19), (35),
(7), (20), (8), (36), (219), (22), (10), (23), (37), (11), (24);
CREATE TABLE `t2` (`type` int , `id` int(32) NOT NULL primary key);
INSERT INTO `t2` VALUES
(2,2),(2,3),(1,4),(2,5),(1,6),(1,19),(5,7),(1,20),(1,8),(1,21),(1,9),
(1,22),(2,10),(1,23),(2,11),(1,24),(1,12),(1,25),(2,13),(2,26),(2,14),
(2,27),(1,15),(1,28),(3,16),(1,29),(2,17),(1,30),(5,18),(2,1);
CREATE TABLE `t3` (`ref_id` int(32) unsigned ,`type` varchar(80),`id` int(32) NOT NULL );
INSERT INTO `t3` VALUES
(1,'incident',31),(2,'faux pas',32),
(5,'oopsies',33),(3,'deniable',34),
(11,'wasntme',35),(10,'wasntme',36),
(17,'faux pas',37),(13,'unlikely',38),
(13,'improbable',39),(14,'incident',40),
(26,'problem',41),(14,'problem',42),
(26,'incident',43),(27,'incident',44);
explain
SELECT t2.id FROM t2,t1
WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 30 Using index
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 Using where
1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using index
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 14
2 MATERIALIZED t1 eq_ref PRIMARY PRIMARY 4 test.t3.id 1 Using index
SELECT t2.id FROM t2,t1
WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
id
10
11
set optimizer_switch='materialization=off';
SELECT t2.id FROM t2,t1
WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
id
11
10
set optimizer_switch='materialization=on';
DROP TABLE t1,t2,t3;
#
# MDEV-15247: Crash when SET NAMES 'utf8' is set
#
CREATE TABLE t1 (

View file

@ -2431,6 +2431,99 @@ ec70316637232000158bbfc8bcbe5d60
ebb4620037332000158bbfc8bcbe5d89
DROP TABLE t1,t2,t3;
set optimizer_switch=@save_optimizer_switch;
#
# MDEV-16751: Server crashes in st_join_table::cleanup or
# TABLE_LIST::is_with_table_recursive_reference with join_cache_level>2
#
set @save_join_cache_level= @@join_cache_level;
set join_cache_level=4;
CREATE TABLE t1 ( id int NOT NULL);
INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL) ;
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)
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
1
1
1
set @@join_cache_level= @save_join_cache_level;
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
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
1
1
1
drop table t1,t2;
#
# MDEV-15454: Nested SELECT IN returns wrong results
#
CREATE TABLE t1 ( a int NOT NULL PRIMARY KEY);
CREATE TABLE t2 ( a int, b int );
INSERT INTO t2 VALUES (7878, 96),(3465, 96),(1403, 96),(4189, 96),(8732, 96), (5,96);
CREATE TABLE t3 (c int unsigned NOT NULL, b int unsigned NOT NULL, PRIMARY KEY (c,b));
INSERT INTO t3 (c, b) VALUES (27, 96);
CREATE PROCEDURE prepare_data()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE i < 1000 DO
INSERT INTO t1 (a) VALUES (i);
INSERT INTO t2 (a,b) VALUES (i,56);
INSERT INTO t3 (c,b) VALUES (i,i);
SET i = i + 1;
END WHILE;
END$$
CALL prepare_data();
SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27);
a
7878
3465
1403
4189
8732
5
set @save_optimizer_switch= @@optimizer_switch;
SET optimizer_switch='materialization=off';
SELECT t1.a FROM t1
WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
a
5
SET optimizer_switch='materialization=on';
SELECT t1.a FROM t1
WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
a
5
drop procedure prepare_data;
set @@optimizer_switch= @save_optimizer_switch;
drop table t1,t2,t3;
CREATE TABLE t1 ( id int NOT NULL, key(id));
INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL);
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
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
1
1
1
drop table t1,t2;
drop view v1;
# End of 5.5 tests
#
# MDEV-7220: Materialization strategy is not used for REPLACE ... SELECT

View file

@ -2112,6 +2112,22 @@ DROP VIEW v1;
UNION
(SELECT 2, 2);
ERROR 42S02: Table 'test.v1' doesn't exist
#
# Bug#27197235 USER VARIABLE + UINON + DECIMAL COLUMN RETURNS
# WRONG VALUES
#
SET NAMES utf8;
SET @advertAcctId = 1000003;
select @advertAcctId as a from dual union all select 1.0 from dual;
a
1000003.0
1.0
SET NAMES latin1;
SET @advertAcctId = 1000003;
select @advertAcctId as a from dual union all select 1.0 from dual;
a
1000003.0
1.0
End of 5.5 tests
#
# WL#1763 Avoid creating temporary table in UNION ALL

View file

@ -0,0 +1,31 @@
# This file runs the query and checks
# whether the size of binlog is increased or not
# If size is changed it issue die command
# Parameters
# $sql_query = query to run
#Only last row of show binlog events matter
--let $tmp= 0
--let $counter= 1
while ($tmp != "No such row")
{
--let $initial_binlog_size= $tmp
--let $tmp= query_get_value(show binary logs, File_size, $counter)
--inc $counter
}
--eval $sql_query
--let $tmp= 0
--let $counter= 1
while ($tmp != "No such row")
{
--let $current_binlog_size= $tmp
--let $tmp= query_get_value(show binary logs, File_size, $counter)
--inc $counter
}
if ($initial_binlog_size != $current_binlog_size)
{
die "Binlog size changed";
}

View file

@ -0,0 +1,7 @@
RESET MASTER;
#Create table test
create temporary table t1(a int, b int);
#Add index test
create index index_a on t1(a);
#drop index test
drop index index_a on t1;

View file

@ -0,0 +1,30 @@
# ==== Purpose ====
#
# Test if statements used temporary tables are not binlogged in the case of
# binlog_format=row
#
# ==== Method ====
#
# We will see if binlog file size is increased or not, It should be constant for the
# entire period of test.
#
# ==== Related bugs ====
#
# Mdev-9266
#
source include/have_log_bin.inc;
source include/have_binlog_format_row.inc;
RESET MASTER;
--echo #Create table test
--let $sql_query= create temporary table t1(a int, b int)
--source suite/binlog/include/check_binlog_size.inc
--echo #Add index test
--let $sql_query= create index index_a on t1(a)
--source suite/binlog/include/check_binlog_size.inc
--echo #drop index test
--let $sql_query= drop index index_a on t1
--source suite/binlog/include/check_binlog_size.inc

View file

@ -0,0 +1,33 @@
SELECT @@innodb_stats_persistent;
@@innodb_stats_persistent
1
CREATE TABLE t1 (f1 INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, f2 INTEGER DEFAULT 1) ENGINE=InnoDB;
INSERT INTO t1(f1) values (NULL);
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
SELECT count(1) from t1;
count(1)
16384
connection node_2;
SET AUTOCOMMIT=OFF;
INSERT INTO t1 VALUES (9999999,NULL);
SELECT SLEEP(1000);;
connection node_1;
ALTER TABLE t1 CHANGE f2 f2 INTEGER NOT NULL DEFAULT 1;
connection node_2;
ERROR 40001: Deadlock: wsrep aborted transaction
wsrep_local_aborts_increment
1
DROP TABLE t1;

View file

@ -60,7 +60,95 @@ INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
connection node_2;
Loading wsrep provider ...
Starting server ...
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES ('node2_committed_after');
INSERT INTO t1 VALUES ('node2_committed_after');
INSERT INTO t1 VALUES ('node2_committed_after');
INSERT INTO t1 VALUES ('node2_committed_after');
INSERT INTO t1 VALUES ('node2_committed_after');
COMMIT;
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
COMMIT;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES ('node1_committed_after');
INSERT INTO t1 VALUES ('node1_committed_after');
INSERT INTO t1 VALUES ('node1_committed_after');
INSERT INTO t1 VALUES ('node1_committed_after');
INSERT INTO t1 VALUES ('node1_committed_after');
COMMIT;
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
ROLLBACK;
SELECT COUNT(*) = 35 FROM t1;
COUNT(*) = 35
1
SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
COUNT(*) = 0
1
COMMIT;
SET AUTOCOMMIT=ON;
SELECT COUNT(*) = 35 FROM t1;
COUNT(*) = 35
1
SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1;
COUNT(*) = 0
1
DROP TABLE t1;
COMMIT;
SET AUTOCOMMIT=ON;
Performing State Transfer on a server that has been killed and restarted
CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES ('node1_committed_before');
INSERT INTO t1 VALUES ('node1_committed_before');
INSERT INTO t1 VALUES ('node1_committed_before');
INSERT INTO t1 VALUES ('node1_committed_before');
INSERT INTO t1 VALUES ('node1_committed_before');
COMMIT;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES ('node2_committed_before');
INSERT INTO t1 VALUES ('node2_committed_before');
INSERT INTO t1 VALUES ('node2_committed_before');
INSERT INTO t1 VALUES ('node2_committed_before');
INSERT INTO t1 VALUES ('node2_committed_before');
COMMIT;
Killing server ...
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES ('node1_committed_during');
INSERT INTO t1 VALUES ('node1_committed_during');
INSERT INTO t1 VALUES ('node1_committed_during');
INSERT INTO t1 VALUES ('node1_committed_during');
INSERT INTO t1 VALUES ('node1_committed_during');
COMMIT;
START TRANSACTION;
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
INSERT INTO t1 VALUES ('node1_to_be_committed_after');
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after');
Performing --wsrep-recover ...
Starting server ...
Using --wsrep-start-position when starting mysqld ...
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES ('node2_committed_after');

View file

@ -0,0 +1 @@
--innodb_stats_persistent=ON

View file

@ -0,0 +1,49 @@
--source include/galera_cluster.inc
--source include/have_innodb.inc
#
# Test a local transaction being aborted by a slave one while it is running a SLEEP()
#
SELECT @@innodb_stats_persistent;
CREATE TABLE t1 (f1 INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, f2 INTEGER DEFAULT 1) ENGINE=InnoDB;
INSERT INTO t1(f1) values (NULL);
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
INSERT INTO t1(f1) select NULL from t1;
SELECT count(1) from t1;
--connection node_2
SET AUTOCOMMIT=OFF;
--let $wsrep_local_bf_aborts_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'`
INSERT INTO t1 VALUES (9999999,NULL);
--send SELECT SLEEP(1000);
--connection node_1
ALTER TABLE t1 CHANGE f2 f2 INTEGER NOT NULL DEFAULT 1;
--connection node_2
--error ER_LOCK_DEADLOCK
--reap
--let $wsrep_local_bf_aborts_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'`
# Check that wsrep_local_bf_aborts has been incremented by exactly 1
--disable_query_log
--eval SELECT $wsrep_local_bf_aborts_after - $wsrep_local_bf_aborts_before = 1 AS wsrep_local_aborts_increment;
--enable_query_log
DROP TABLE t1;

View file

@ -19,7 +19,12 @@ GRANT USAGE ON *.* TO sslsst REQUIRE SSL;
SET GLOBAL wsrep_sst_auth = 'sslsst:';
--source suite/galera/include/galera_st_disconnect_slave.inc
# We set the required mysqldump SST options here so that they are used every time the server is restarted during the test
--let $start_mysqld_params = --wsrep_sst_auth=sst:'sslsst:' --wsrep_sst_method=mysqldump --wsrep-sst-receive-address=127.0.0.1:$NODE_MYPORT_2 --skip-grant-tables
--source suite/galera/include/galera_st_shutdown_slave.inc
--source suite/galera/include/galera_st_kill_slave.inc
--source suite/galera/include/galera_st_kill_slave_ddl.inc
--source include/auto_increment_offset_restore.inc
--source suite/galera/include/galera_sst_restore.inc

View file

@ -30,7 +30,7 @@ SET GLOBAL innodb_default_row_format=Dynamic;
CREATE TABLE tab(a INT) ENGINE=InnoDB;
ALTER TABLE tab DISCARD TABLESPACE;
ALTER TABLE tab IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x1)
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x1; .cfg file uses ROW_FORMAT=COMPACT)
DROP TABLE tab;
SET GLOBAL innodb_default_row_format=Compact;
SELECT @@innodb_default_row_format;

View file

@ -109,7 +109,7 @@ ALTER TABLE t2 DISCARD TABLESPACE;
# List after t2 DISCARD
t2.frm
ALTER TABLE t2 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x1)
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x1; .cfg file uses ROW_FORMAT=COMPACT)
ALTER TABLE t2 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Expected FSP_SPACE_FLAGS=0x*, .ibd file contains 0x*.)
DROP TABLE t2;
@ -589,7 +589,7 @@ SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x1 and the meta-data file has 0x0)
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x1 and the meta-data file has 0x0; .cfg file uses ROW_FORMAT=REDUNDANT)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
@ -601,7 +601,19 @@ SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x0)
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x0; .cfg file uses ROW_FORMAT=REDUNDANT)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
ALTER TABLE t1 DISCARD TABLESPACE;
SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x29 and the meta-data file has 0x0; .cfg file uses ROW_FORMAT=REDUNDANT)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
@ -775,7 +787,7 @@ SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x0 and the meta-data file has 0x1)
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x0 and the meta-data file has 0x1; .cfg file uses ROW_FORMAT=COMPACT)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
@ -787,7 +799,19 @@ SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x1)
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x1; .cfg file uses ROW_FORMAT=COMPACT)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
ALTER TABLE t1 DISCARD TABLESPACE;
SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x29 and the meta-data file has 0x1; .cfg file uses ROW_FORMAT=COMPACT)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
@ -964,7 +988,7 @@ SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x1 and the meta-data file has 0x21)
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x1 and the meta-data file has 0x21; .cfg file uses ROW_FORMAT=DYNAMIC)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
@ -976,7 +1000,19 @@ SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x0 and the meta-data file has 0x21)
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x0 and the meta-data file has 0x21; .cfg file uses ROW_FORMAT=DYNAMIC)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
ALTER TABLE t1 DISCARD TABLESPACE;
SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x29 and the meta-data file has 0x21; .cfg file uses ROW_FORMAT=DYNAMIC)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
@ -1035,6 +1071,220 @@ c1 c2
42 1
43 1
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
INSERT INTO t1(c2) VALUES(1);
INSERT INTO t1(c2) SELECT c2 FROM t1;
INSERT INTO t1(c2) SELECT c2 FROM t1;
INSERT INTO t1(c2) SELECT c2 FROM t1;
INSERT INTO t1(c2) SELECT c2 FROM t1;
INSERT INTO t1(c2) SELECT c2 FROM t1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
`c2` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `idx` (`c2`)
) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED
SELECT * FROM t1;
c1 c2
1 1
2 1
3 1
4 1
6 1
7 1
8 1
9 1
13 1
14 1
15 1
16 1
17 1
18 1
19 1
20 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 1
37 1
38 1
39 1
40 1
41 1
42 1
43 1
FLUSH TABLES t1 FOR EXPORT;
backup: t1
UNLOCK TABLES;
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
ALTER TABLE t1 DISCARD TABLESPACE;
SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
unlink: t1.cfg
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
`c2` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `idx` (`c2`)
) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED
SELECT * FROM t1;
c1 c2
1 1
2 1
3 1
4 1
6 1
7 1
8 1
9 1
13 1
14 1
15 1
16 1
17 1
18 1
19 1
20 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 1
37 1
38 1
39 1
40 1
41 1
42 1
43 1
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
ALTER TABLE t1 DISCARD TABLESPACE;
SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x0 and the meta-data file has 0x29; .cfg file uses ROW_FORMAT=COMPRESSED)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPACT;
ALTER TABLE t1 DISCARD TABLESPACE;
SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x1 and the meta-data file has 0x29; .cfg file uses ROW_FORMAT=COMPRESSED)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
ALTER TABLE t1 DISCARD TABLESPACE;
SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x21 and the meta-data file has 0x29; .cfg file uses ROW_FORMAT=COMPRESSED)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB
ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1;
ALTER TABLE t1 DISCARD TABLESPACE;
SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
ERROR HY000: Schema mismatch (Table flags don't match, server table has 0x23 and the meta-data file has 0x29; .cfg file uses ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8)
unlink: t1.ibd
unlink: t1.cfg
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
ALTER TABLE t1 DISCARD TABLESPACE;
SELECT * FROM t1;
ERROR HY000: Tablespace has been discarded for table `t1`
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
unlink: t1.cfg
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) NOT NULL AUTO_INCREMENT,
`c2` int(11) DEFAULT NULL,
PRIMARY KEY (`c1`),
KEY `idx` (`c2`)
) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED
SELECT * FROM t1;
c1 c2
1 1
2 1
3 1
4 1
6 1
7 1
8 1
9 1
13 1
14 1
15 1
16 1
17 1
18 1
19 1
20 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 1
37 1
38 1
39 1
40 1
41 1
42 1
43 1
DROP TABLE t1;
call mtr.add_suppression("Got error -1 when reading table '.*'");
call mtr.add_suppression("InnoDB: Error: tablespace id and flags in file '.*'.*");
call mtr.add_suppression("InnoDB: The table .* doesn't have a corresponding tablespace, it was discarded");

View file

@ -72,7 +72,7 @@ DROP TABLE t1;
Warnings:
Warning 1932 Table 'test.t1' doesn't exist in engine
DROP TABLE t2,t3;
FOUND 49 /\[ERROR\] InnoDB: Table `test`\.`t1` in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=1 SYS_TABLES\.MIX_LEN=255\b/ in mysqld.1.err
FOUND 50 /\[ERROR\] InnoDB: Table `test`\.`t1` in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=1 SYS_TABLES\.MIX_LEN=255\b/ in mysqld.1.err
ib_buffer_pool
ib_logfile0
ib_logfile1

View file

@ -486,7 +486,7 @@ SELECT * FROM t1;
DROP TABLE t1;
#
# Row format tests [EXPORT REDUNDANT - IMPORT COMPACT & DYNAMIC]
# EXPORT ROW_FORMAT=REDUNDANT
#
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
@ -588,6 +588,29 @@ EOF
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
ALTER TABLE t1 DISCARD TABLESPACE;
--error ER_TABLESPACE_DISCARDED
SELECT * FROM t1;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_discard_tablespaces("test", "t1");
ib_restore_tablespaces("test", "t1");
EOF
--error ER_TABLE_SCHEMA_MISMATCH
ALTER TABLE t1 IMPORT TABLESPACE;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_unlink_tablespace("test", "t1");
EOF
DROP TABLE t1;
# This should be OK.
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
@ -616,7 +639,7 @@ SELECT * FROM t1;
DROP TABLE t1;
#
# Row format tests [EXPORT COMPACT - IMPORT REDUNDANT & DYNAMIC]
# EXPORT ROW_FORMAT=COMPACT
#
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
@ -718,6 +741,29 @@ EOF
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
ALTER TABLE t1 DISCARD TABLESPACE;
--error ER_TABLESPACE_DISCARDED
SELECT * FROM t1;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_discard_tablespaces("test", "t1");
ib_restore_tablespaces("test", "t1");
EOF
--error ER_TABLE_SCHEMA_MISMATCH
ALTER TABLE t1 IMPORT TABLESPACE;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_unlink_tablespace("test", "t1");
EOF
DROP TABLE t1;
# This should be OK.
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
@ -747,7 +793,7 @@ SELECT * FROM t1;
DROP TABLE t1;
#
# Row format tests [EXPORT DYNAMIC- IMPORT REDUNDANT & DYNAMIC]
# EXPORT ROW_FORMAT=DYNAMIC
#
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
@ -849,6 +895,29 @@ EOF
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
ALTER TABLE t1 DISCARD TABLESPACE;
--error ER_TABLESPACE_DISCARDED
SELECT * FROM t1;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_discard_tablespaces("test", "t1");
ib_restore_tablespaces("test", "t1");
EOF
--error ER_TABLE_SCHEMA_MISMATCH
ALTER TABLE t1 IMPORT TABLESPACE;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_unlink_tablespace("test", "t1");
EOF
DROP TABLE t1;
# This should be OK.
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
@ -877,6 +946,185 @@ SELECT * FROM t1;
DROP TABLE t1;
#
# EXPORT ROW_FORMAT=COMPRESSED
#
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
INSERT INTO t1(c2) VALUES(1);
INSERT INTO t1(c2) SELECT c2 FROM t1;
INSERT INTO t1(c2) SELECT c2 FROM t1;
INSERT INTO t1(c2) SELECT c2 FROM t1;
INSERT INTO t1(c2) SELECT c2 FROM t1;
INSERT INTO t1(c2) SELECT c2 FROM t1;
SHOW CREATE TABLE t1;
SELECT * FROM t1;
FLUSH TABLES t1 FOR EXPORT;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_backup_tablespaces("test", "t1");
EOF
UNLOCK TABLES;
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
ALTER TABLE t1 DISCARD TABLESPACE;
--error ER_TABLESPACE_DISCARDED
SELECT * FROM t1;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_discard_tablespaces("test", "t1");
ib_restore_tablespaces("test", "t1");
EOF
ALTER TABLE t1 IMPORT TABLESPACE;
CHECK TABLE t1;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_cleanup("test", "t1");
EOF
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
ALTER TABLE t1 DISCARD TABLESPACE;
--error ER_TABLESPACE_DISCARDED
SELECT * FROM t1;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_discard_tablespaces("test", "t1");
ib_restore_tablespaces("test", "t1");
EOF
--error ER_TABLE_SCHEMA_MISMATCH
ALTER TABLE t1 IMPORT TABLESPACE;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_unlink_tablespace("test", "t1");
EOF
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPACT;
ALTER TABLE t1 DISCARD TABLESPACE;
--error ER_TABLESPACE_DISCARDED
SELECT * FROM t1;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_discard_tablespaces("test", "t1");
ib_restore_tablespaces("test", "t1");
EOF
--error ER_TABLE_SCHEMA_MISMATCH
ALTER TABLE t1 IMPORT TABLESPACE;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_unlink_tablespace("test", "t1");
EOF
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
ALTER TABLE t1 DISCARD TABLESPACE;
--error ER_TABLESPACE_DISCARDED
SELECT * FROM t1;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_discard_tablespaces("test", "t1");
ib_restore_tablespaces("test", "t1");
EOF
--error ER_TABLE_SCHEMA_MISMATCH
ALTER TABLE t1 IMPORT TABLESPACE;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_unlink_tablespace("test", "t1");
EOF
DROP TABLE t1;
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB
ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1;
ALTER TABLE t1 DISCARD TABLESPACE;
--error ER_TABLESPACE_DISCARDED
SELECT * FROM t1;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_discard_tablespaces("test", "t1");
ib_restore_tablespaces("test", "t1");
EOF
--error ER_TABLE_SCHEMA_MISMATCH
ALTER TABLE t1 IMPORT TABLESPACE;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_unlink_tablespace("test", "t1");
EOF
DROP TABLE t1;
# This should be OK.
CREATE TABLE t1(
c1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
c2 INT, INDEX idx(c2)) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
ALTER TABLE t1 DISCARD TABLESPACE;
--error ER_TABLESPACE_DISCARDED
SELECT * FROM t1;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_discard_tablespaces("test", "t1");
ib_restore_tablespaces("test", "t1");
EOF
ALTER TABLE t1 IMPORT TABLESPACE;
CHECK TABLE t1;
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_cleanup("test", "t1");
EOF
SHOW CREATE TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
call mtr.add_suppression("Got error -1 when reading table '.*'");
call mtr.add_suppression("InnoDB: Error: tablespace id and flags in file '.*'.*");
call mtr.add_suppression("InnoDB: The table .* doesn't have a corresponding tablespace, it was discarded");

View file

@ -0,0 +1,9 @@
CREATE TABLE t1 (a VARCHAR(7), b text, FULLTEXT KEY idx (a,b)) ENGINE=InnoDB;
COMMIT;
SELECT COUNT(*) FROM t1
WHERE MATCH (a,b) AGAINST ('foo bar' IN BOOLEAN MODE);
connect con1,localhost,root,,;
KILL QUERY @id;
disconnect con1;
connection default;
DROP TABLE t1;

View file

@ -0,0 +1,117 @@
CREATE TABLE t1 (
id INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
value VARCHAR(1024)
) ENGINE=InnoDB;
CREATE FULLTEXT INDEX idx1 ON t1(value);
Warnings:
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID
SET @save_debug = @@GLOBAL.debug_dbug;
SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_sync_before_syncing,ib_trunc_sleep_before_fts_cache_clear';
INSERT INTO t1 (value) VALUES
('By default or with the IN NATURAL LANGUAGE MODE modifier')
;
TRUNCATE TABLE t1;
DROP TABLE t1;
SET GLOBAL debug_dbug = @save_debug;
CREATE TABLE t1 (
id INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
value VARCHAR(1024)
) ENGINE=InnoDB;
CREATE FULLTEXT INDEX idx1 ON t1(value);
Warnings:
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID
SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_write_words_before_select_index,ib_trunc_sleep_before_fts_cache_clear';
INSERT INTO t1 (value) VALUES
('By default or with the IN NATURAL LANGUAGE MODE modifier'),
('performs a natural language search for a string'),
('collection is a set of one or more columns included'),
('returns a relevance value; that is, a similarity measure'),
('and the text in that row in the columns named in'),
('By default, the search is performed in case-insensitive'),
('sensitive full-text search, use a binary collation '),
('example, a column that uses the latin1 character'),
('collation of latin1_bin to make it case sensitive')
;
TRUNCATE TABLE t1;
DROP TABLE t1;
SET GLOBAL debug_dbug = @save_debug;
CREATE TABLE t1 (
value VARCHAR(1024)
) ENGINE=InnoDB;
CREATE FULLTEXT INDEX idx1 ON t1(value);
Warnings:
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID
SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_msg_sync_sleep';
INSERT INTO t1 (value) VALUES
('By default or with the IN NATURAL LANGUAGE MODE modifier'),
('performs a natural language search for a string'),
('collection is a set of one or more columns included'),
('returns a relevance value; that is, a similarity measure'),
('and the text in that row in the columns named in'),
('By default, the search is performed in case-insensitive'),
('sensitive full-text search, use a binary collation '),
('example, a column that uses the latin1 character'),
('collation of latin1_bin to make it case sensitive')
;
DROP INDEX idx1 ON t1;
DROP TABLE t1;
SET GLOBAL debug_dbug = @save_debug;
CREATE TABLE t1 (
value VARCHAR(1024)
) ENGINE=InnoDB;
CREATE FULLTEXT INDEX idx1 ON t1(value);
Warnings:
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID
SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_msg_sync_sleep';
INSERT INTO t1 (value) VALUES
('By default or with the IN NATURAL LANGUAGE MODE modifier'),
('performs a natural language search for a string'),
('collection is a set of one or more columns included'),
('returns a relevance value; that is, a similarity measure'),
('and the text in that row in the columns named in'),
('By default, the search is performed in case-insensitive'),
('sensitive full-text search, use a binary collation '),
('example, a column that uses the latin1 character'),
('collation of latin1_bin to make it case sensitive')
;
ALTER TABLE t1
DROP INDEX idx1,
ALGORITHM=INPLACE;
DROP TABLE t1;
SET GLOBAL debug_dbug = @save_debug;
CREATE TABLE t1 (
value VARCHAR(1024)
) ENGINE=InnoDB;
CREATE FULLTEXT INDEX idx1 ON t1(value);
Warnings:
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID
SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_msg_sync_sleep';
INSERT INTO t1 (value) VALUES
('example, a column that uses the latin1 character'),
('collation of latin1_bin to make it case sensitive')
;
ALTER TABLE t1
DROP INDEX idx1,
ALGORITHM=COPY;
DROP TABLE t1;
SET GLOBAL debug_dbug = @save_debug;
CREATE TABLE t1 (
id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
value VARCHAR(1024)
) ENGINE=InnoDB;
CREATE FULLTEXT INDEX idx1 ON t1(value);
Warnings:
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID
SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_msg_sync_sleep';
INSERT INTO t1 (value) VALUES
('example, a column that uses the latin1 character'),
('collation of latin1_bin to make it case sensitive')
;
ALTER TABLE t1
DROP COLUMN id1,
ADD COLUMN id2 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
DROP INDEX idx1,
ADD FULLTEXT INDEX idx2(value),
ALGORITHM=INPLACE;
DROP TABLE t1;
SET GLOBAL debug_dbug = @save_debug;

View file

@ -0,0 +1,30 @@
--source include/have_innodb.inc
CREATE TABLE t1 (a VARCHAR(7), b text, FULLTEXT KEY idx (a,b)) ENGINE=InnoDB;
--disable_query_log
BEGIN;
let $n=1000;
while ($n) {
INSERT INTO t1 VALUES('foo bar','boo far');
dec $n;
}
--enable_query_log
COMMIT;
let $id = `SELECT CONNECTION_ID()`;
send SELECT COUNT(*) FROM t1
WHERE MATCH (a,b) AGAINST ('foo bar' IN BOOLEAN MODE);
connect (con1,localhost,root,,);
let $ignore= `SELECT @id := $ID`;
KILL QUERY @id;
disconnect con1;
connection default;
# The following would return a result set if the KILL was not fast enough.
--disable_result_log
--error 0,ER_QUERY_INTERRUPTED,HA_ERR_ABORTED_BY_USER
reap;
--enable_result_log
DROP TABLE t1;

View file

@ -0,0 +1,177 @@
#
# BUG#27082268 FTS synchronization issues
#
--source include/have_innodb.inc
--source include/have_debug.inc
#--------------------------------------
# Check FTS_sync vs TRUNCATE (1)
#--------------------------------------
CREATE TABLE t1 (
id INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
value VARCHAR(1024)
) ENGINE=InnoDB;
CREATE FULLTEXT INDEX idx1 ON t1(value);
SET @save_debug = @@GLOBAL.debug_dbug;
SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_sync_before_syncing,ib_trunc_sleep_before_fts_cache_clear';
INSERT INTO t1 (value) VALUES
('By default or with the IN NATURAL LANGUAGE MODE modifier')
;
TRUNCATE TABLE t1;
DROP TABLE t1;
SET GLOBAL debug_dbug = @save_debug;
#--------------------------------------
# Check FTS sync vs DROP INDEX (2)
#--------------------------------------
CREATE TABLE t1 (
id INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
value VARCHAR(1024)
) ENGINE=InnoDB;
CREATE FULLTEXT INDEX idx1 ON t1(value);
SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_write_words_before_select_index,ib_trunc_sleep_before_fts_cache_clear';
INSERT INTO t1 (value) VALUES
('By default or with the IN NATURAL LANGUAGE MODE modifier'),
('performs a natural language search for a string'),
('collection is a set of one or more columns included'),
('returns a relevance value; that is, a similarity measure'),
('and the text in that row in the columns named in'),
('By default, the search is performed in case-insensitive'),
('sensitive full-text search, use a binary collation '),
('example, a column that uses the latin1 character'),
('collation of latin1_bin to make it case sensitive')
;
TRUNCATE TABLE t1;
DROP TABLE t1;
SET GLOBAL debug_dbug = @save_debug;
#--------------------------------------
# Check FTS sync vs DROP INDEX
#--------------------------------------
CREATE TABLE t1 (
value VARCHAR(1024)
) ENGINE=InnoDB;
CREATE FULLTEXT INDEX idx1 ON t1(value);
SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_msg_sync_sleep';
INSERT INTO t1 (value) VALUES
('By default or with the IN NATURAL LANGUAGE MODE modifier'),
('performs a natural language search for a string'),
('collection is a set of one or more columns included'),
('returns a relevance value; that is, a similarity measure'),
('and the text in that row in the columns named in'),
('By default, the search is performed in case-insensitive'),
('sensitive full-text search, use a binary collation '),
('example, a column that uses the latin1 character'),
('collation of latin1_bin to make it case sensitive')
;
DROP INDEX idx1 ON t1;
DROP TABLE t1;
SET GLOBAL debug_dbug = @save_debug;
#--------------------------------------
# Check FTS sync vs ALTER TABLE DROP INDEX (INPLACE)
#--------------------------------------
CREATE TABLE t1 (
value VARCHAR(1024)
) ENGINE=InnoDB;
CREATE FULLTEXT INDEX idx1 ON t1(value);
SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_msg_sync_sleep';
INSERT INTO t1 (value) VALUES
('By default or with the IN NATURAL LANGUAGE MODE modifier'),
('performs a natural language search for a string'),
('collection is a set of one or more columns included'),
('returns a relevance value; that is, a similarity measure'),
('and the text in that row in the columns named in'),
('By default, the search is performed in case-insensitive'),
('sensitive full-text search, use a binary collation '),
('example, a column that uses the latin1 character'),
('collation of latin1_bin to make it case sensitive')
;
ALTER TABLE t1
DROP INDEX idx1,
ALGORITHM=INPLACE;
DROP TABLE t1;
SET GLOBAL debug_dbug = @save_debug;
#--------------------------------------
# Check FTS sync vs ALTER TABLE DROP INDEX (COPY)
#--------------------------------------
CREATE TABLE t1 (
value VARCHAR(1024)
) ENGINE=InnoDB;
CREATE FULLTEXT INDEX idx1 ON t1(value);
SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_msg_sync_sleep';
INSERT INTO t1 (value) VALUES
('example, a column that uses the latin1 character'),
('collation of latin1_bin to make it case sensitive')
;
ALTER TABLE t1
DROP INDEX idx1,
ALGORITHM=COPY;
DROP TABLE t1;
SET GLOBAL debug_dbug = @save_debug;
#--------------------------------------
# Check FTS sync vs ALTER TABLE (INPLACE, new cluster)
#--------------------------------------
CREATE TABLE t1 (
id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
value VARCHAR(1024)
) ENGINE=InnoDB;
CREATE FULLTEXT INDEX idx1 ON t1(value);
SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_msg_sync_sleep';
INSERT INTO t1 (value) VALUES
('example, a column that uses the latin1 character'),
('collation of latin1_bin to make it case sensitive')
;
ALTER TABLE t1
DROP COLUMN id1,
ADD COLUMN id2 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
DROP INDEX idx1,
ADD FULLTEXT INDEX idx2(value),
ALGORITHM=INPLACE;
DROP TABLE t1;
SET GLOBAL debug_dbug = @save_debug;

View file

@ -0,0 +1,7 @@
create table t1 (i int) engine=myisam partition by hash(i) partitions 2 ;
lock table t1 write;
truncate table t1;
desc t1;
Field Type Null Key Default Extra
i int(11) YES NULL
drop table t1;

View file

@ -0,0 +1,10 @@
#
# MDEV-15551 Server hangs or assertion `strcmp(share->unique_file_name,filename) || share->last_version' fails in test_if_reopen or unexpected ER_LOCK_DEADLOCK
#
--source include/have_partition.inc
create table t1 (i int) engine=myisam partition by hash(i) partitions 2 ;
lock table t1 write;
truncate table t1;
desc t1;
drop table t1;

View file

@ -1210,7 +1210,7 @@
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_VERSION
SESSION_VALUE NULL
-GLOBAL_VALUE 5.6.40
-GLOBAL_VALUE 5.6.41
+GLOBAL_VALUE 5.6.39-83.1
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE NULL

View file

@ -1,5 +1,5 @@
--- suite/sys_vars/r/sysvars_innodb.result
+++ suite/sys_vars/r/sysvars_innodb,xtradb.reject
--- mysql-test/suite/sys_vars/r/sysvars_innodb.result 2018-07-30 23:41:05.030930072 +0200
+++ mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.reject 2018-07-31 09:45:20.330811949 +0200
@@ -47,6 +47,20 @@
ENUM_VALUE_LIST OFF,ON
READ_ONLY NO
@ -684,7 +684,7 @@
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_VERSION
SESSION_VALUE NULL
-GLOBAL_VALUE 5.6.40
-GLOBAL_VALUE 5.6.41
+GLOBAL_VALUE 5.6.39-83.1
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE NULL

View file

@ -485,6 +485,20 @@ NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME CORE_FILE
SESSION_VALUE NULL
GLOBAL_VALUE ON
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE NULL
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT write a core-file on crashes
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY YES
COMMAND_LINE_ARGUMENT NULL
VARIABLE_NAME DATADIR
SESSION_VALUE NULL
GLOBAL_VALUE PATH

View file

@ -485,6 +485,20 @@ NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME CORE_FILE
SESSION_VALUE NULL
GLOBAL_VALUE ON
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE NULL
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BOOLEAN
VARIABLE_COMMENT write a core-file on crashes
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY YES
COMMAND_LINE_ARGUMENT NULL
VARIABLE_NAME DATADIR
SESSION_VALUE NULL
GLOBAL_VALUE PATH

View file

@ -106,3 +106,12 @@ use test;
EOF
--exec $MYSQLD_BOOTSTRAP_CMD --ignore-db-dirs='some_dir' --ignore-db-dirs='some_dir' < $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1
--remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql
#
# MDEV-13397 MariaDB upgrade fail when using default_time_zone
#
--write_file $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql
use test;
EOF
--exec $MYSQLD_BOOTSTRAP_CMD --default-time-zone=Europe/Moscow < $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1
--remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql

View file

@ -24,6 +24,9 @@ SET NAMES binary;
--echo #
SELECT _binary 0x7E, _binary X'7E', _binary B'01111110';
SET NAMES utf8, character_set_connection=binary;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
--echo #

View file

@ -537,6 +537,8 @@ DROP TABLE t1;
--error ER_INVALID_CHARACTER_STRING
SELECT _eucjpms 0x8EA0;
SET NAMES eucjpms;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests

View file

@ -197,6 +197,16 @@ set collation_connection=euckr_bin;
--echo # End of 5.6 tests
--echo #
--echo #
--echo # Start of 10.0 tests
--echo #
SET NAMES utf8, character_set_connection=euckr;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
--echo #
--echo #
--echo # Start of 10.2 tests

View file

@ -199,6 +199,9 @@ let $ctype_unescape_combinations=selected;
SET NAMES gbk;
--source include/ctype_E05C.inc
SET NAMES utf8, character_set_connection=gbk;
--source include/ctype_mdev13118.inc
--echo #
--echo # MDEV-9886 Illegal mix of collations with a view comparing a field to a binary constant
--echo #

View file

@ -262,6 +262,9 @@ SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1;
SET NAMES latin1;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests

View file

@ -991,6 +991,10 @@ DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
SET NAMES utf8, character_set_connection=ucs2;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
--echo #

View file

@ -1368,6 +1368,10 @@ DROP TABLE t1;
SELECT _ujis 0x8EA0;
SET NAMES ujis;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
--echo #

View file

@ -870,6 +870,11 @@ SET @arg00=_binary 0x00FF;
EXECUTE stmt USING @arg00;
DEALLOCATE PREPARE stmt;
SET NAMES utf8, character_set_connection=utf16;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
--echo #

View file

@ -747,6 +747,19 @@ SET NAMES utf8, collation_connection=utf16le_bin;
--echo # End of 5.6 tests
--echo #
--echo #
--echo # Start of 10.0 tests
--echo #
SET NAMES utf8, character_set_connection=utf16le;
--source include/ctype_mdev13118.inc
--echo #
--echo # Start of 10.0 tests
--echo #
--echo #
--echo # Start of 10.1 tests
--echo #

View file

@ -983,6 +983,14 @@ SET @arg00=_binary 0x00FF;
EXECUTE stmt USING @arg00;
DEALLOCATE PREPARE stmt;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET NAMEs utf8, character_set_connection=utf32;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
--echo #

View file

@ -1890,6 +1890,13 @@ SELECT * FROM v1;
DROP VIEW v1;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET NAMES utf8;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
--echo #

View file

@ -1959,6 +1959,14 @@ DROP TABLE t1;
SET NAMES default;
#
# MDEV-13118 Wrong results with LOWER and UPPER and subquery
#
SET NAMES utf8mb4;
--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
--echo #

View file

@ -913,6 +913,7 @@ CREATE TABLE t3 (c VARCHAR(1024) CHARACTER SET utf8, d INT) ENGINE=MyISAM;
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3;
INSERT INTO t3 VALUES ('abc',NULL),('def',4);
set @save_join_cache_level= @@join_cache_level;
SET join_cache_level= 8;
explain
SELECT * FROM v1, t2, v3 WHERE a = c AND b = d;
@ -935,7 +936,27 @@ call pr(2);
drop procedure pr;
drop view v1;
drop table t1;
set @@join_cache_level= @save_join_cache_level;
--echo #
--echo # MDEV-16307: Incorrect results when using BNLH join instead of BNL join with views
--echo #
CREATE TABLE t1 (c1 text, c2 int);
INSERT INTO t1 VALUES ('a',1), ('c',3), ('g',7), ('d',4), ('c',3);
CREATE TABLE t2 (c1 text, c2 int);
INSERT INTO t2 VALUES ('b',2), ('c',3);
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
explain SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
set @save_join_cache_level= @@join_cache_level;
set @@join_cache_level=4;
explain SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
drop table t1,t2;
drop view v1;
set @@join_cache_level= @save_join_cache_level;
--echo # end of 5.5
--echo #

View file

@ -1598,6 +1598,9 @@ use test;
#
# Bug#16470 crash on grant if old grant tables
#
call mtr.add_suppression("Can't open and lock privilege tables");
--echo FLUSH PRIVILEGES without procs_priv table.
RENAME TABLE mysql.procs_priv TO mysql.procs_gone;
FLUSH PRIVILEGES;

View file

@ -1160,6 +1160,59 @@ DROP TABLE t1,t2;
SET optimizer_switch=@save_optimizer_switch;
--echo #
--echo # MDEV-16512
--echo # Server crashes in find_field_in_table_ref on 2nd execution of SP referring to
--echo # non-existing field
--echo #
CREATE TABLE t (i INT);
CREATE PROCEDURE p() SELECT t1.f FROM t AS t1 JOIN t AS t2 USING (f);
--error ER_BAD_FIELD_ERROR
CALL p;
--error ER_BAD_FIELD_ERROR
CALL p;
FLUSH TABLES;
--error ER_BAD_FIELD_ERROR
CALL p;
DROP TABLE t;
#
# Fix the table definition to match the using
#
CREATE TABLE t (f INT);
#
# The following shouldn't fail as the table is now matching the using
#
--error ER_BAD_FIELD_ERROR
CALL p;
DROP TABLE t;
CREATE TABLE t (i INT);
--error ER_BAD_FIELD_ERROR
CALL p;
DROP PROCEDURE p;
DROP TABLE t;
CREATE TABLE t1 (a INT, b INT);
CREATE TABLE t2 (a INT);
CREATE TABLE t3 (a INT, c INT);
CREATE TABLE t4 (a INT, c INT);
CREATE TABLE t5 (a INT, c INT);
CREATE PROCEDURE p1() SELECT c FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a)
LEFT JOIN t5 USING (a)) USING (a);
--error ER_NON_UNIQ_ERROR
CALL p1;
--error ER_NON_UNIQ_ERROR
CALL p1;
DROP PROCEDURE p1;
DROP TABLE t1,t2,t3,t4,t5;
--echo #
--echo # End of MariaDB 5.5 tests
--echo #
--echo #
--echo # Bug #35268: Parser can't handle STRAIGHT_JOIN with USING
--echo #

View file

@ -3869,6 +3869,37 @@ set optimizer_switch=@save_optimizer_switch;
DROP TABLE t1,t4,t5,t2;
--echo #
--echo # MDEV-16603: BNLH for query with materialized semi-join
--echo #
--source include/have_innodb.inc
set join_cache_level=4;
CREATE TABLE t1 ( i1 int, v1 varchar(1)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (7,'x');
CREATE TABLE t2 (i1 int, v1 varchar(1), KEY v1 (v1,i1)) ENGINE=InnoDB;
INSERT INTO t2 VALUES
(NULL,'x'),(1,'x'),(3,'x'),(5,'x'),(8,'x'),(48,'x'),
(228,'x'),(3,'y'),(1,'z'),(9,'z');
CREATE TABLE temp
SELECT t1.i1 AS f1, t1.v1 AS f2 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1));
let $q =
SELECT * FROM temp
WHERE (f1,f2) IN (SELECT t1.i1, t1.v1 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1)));
eval $q;
eval EXPLAIN EXTENDED $q;
DROP TABLE t1,t2,temp;
SET join_cache_level = default;
--echo #
--echo # MDEV-5123 Remove duplicated conditions pushed both to join_tab->select_cond and join_tab->cache_select->cond for blocked joins.
--echo #
@ -3958,5 +3989,4 @@ drop table t1, t2;
set join_buffer_size = default;
# The following command must be the last one the file
# this must be the last command in the file
set @@optimizer_switch=@save_optimizer_switch;

View file

@ -1992,6 +1992,54 @@ select * from t1 t
on t.id=r.id ;
drop table t1, t2;
--echo #
--echo # MDEV-16726: SELECT with STRAGHT JOIN containing NESTED RIGHT JOIN
--echo # converted to INNER JOIN with first constant inner table
--echo #
CREATE TABLE t1 (
pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1), KEY v1 (v1,i1)
) engine=MyISAM;
INSERT INTO t1 VALUES
(8,3,'c','c'),(9,4,'z','z'),(10,3,'i','i'),(11,186,'x','x'),
(14,226,'m','m'),(15,133,'p','p');
CREATE TABLE t2 (
pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1)
) engine=MyISAM;
INSERT INTO t2 VALUES (10,6,'p','p');
EXPLAIN EXTENDED
SELECT STRAIGHT_JOIN t2.v2
FROM
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
RIGHT JOIN
(t2,t1)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
EXPLAIN EXTENDED
SELECT STRAIGHT_JOIN t2.v2
FROM
(t2,t1)
LEFT JOIN
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
SELECT STRAIGHT_JOIN DISTINCT t2.v2
FROM
(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
RIGHT JOIN
(t2,t1)
ON t1.pk = t2.pk AND t2.v2 = tb1.v1
WHERE tb1.pk = 40
ORDER BY tb1.i1;
DROP TABLE t1,t2;
--echo # end of 5.5 tests
SET optimizer_switch=@save_optimizer_switch;

View file

@ -141,3 +141,10 @@ select * from tmp;
select * from t2;
drop table tmp,t2;
#
# MDEV-11741 handler::ha_reset(): Assertion `bitmap_is_set_all(&table->s->all_set)' failed or server crash in mi_reset or buffer overrun or unexpected ER_CANT_REMOVE_ALL_FIELDS
#
create table t1 (a int) engine=memory;
--error ER_BAD_DB_ERROR
rename table t1 to non_existent.t2;
drop table t1;

View file

@ -305,4 +305,116 @@ drop database db1;
drop database db2;
drop table t1;
--echo #
--echo # MDEV-16552: [10.0] ASAN global-buffer-overflow in is_stat_table / statistics_for_tables_is_needed
--echo #
SET use_stat_tables = PREFERABLY;
SELECT CONVERT_TZ( '1991-09-20 10:11:02', '+00:00', 'GMT' );
set use_stat_tables=@save_use_stat_tables;
--echo #
--echo # MDEV-16757: manual addition of min/max statistics for BLOB
--echo #
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
--sorted_result
SELECT * FROM mysql.column_stats;
DELETE FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='t';
INSERT INTO mysql.column_stats VALUES
('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
--sorted_result
SELECT * FROM mysql.column_stats;
SELECT pk FROM t1;
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
--echo #
--echo # MDEV-16760: CREATE OR REPLACE TABLE after ANALYZE TABLE
--echo #
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk int PRIMARY KEY, c varchar(32));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
SELECT * FROM t1;
SELECT * FROM mysql.column_stats;
CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
SELECT * FROM t1;
SELECT * FROM mysql.column_stats;
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
--echo #
--echo # MDEV-16757: manual addition of min/max statistics for BLOB
--echo #
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
--sorted_result
SELECT * FROM mysql.column_stats;
DELETE FROM mysql.column_stats
WHERE db_name='test' AND table_name='t1' AND column_name='t';
INSERT INTO mysql.column_stats VALUES
('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
--sorted_result
SELECT * FROM mysql.column_stats;
SELECT pk FROM t1;
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
--echo #
--echo # MDEV-16760: CREATE OR REPLACE TABLE after ANALYZE TABLE
--echo #
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk int PRIMARY KEY, c varchar(32));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
SELECT * FROM t1;
SELECT * FROM mysql.column_stats;
CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
SELECT * FROM t1;
SELECT * FROM mysql.column_stats;
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
--echo #
--echo # MDEV-16711:CREATE OR REPLACE TABLE introducing BLOB column
--echo #
SET use_stat_tables= PREFERABLY;
CREATE TABLE t1 (pk INT PRIMARY KEY, t CHAR(60));
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
ANALYZE TABLE t1;
CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
SELECT MAX(pk) FROM t1;
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;

View file

@ -346,6 +346,55 @@ WHERE (
);
drop table t1;
--echo #
--echo # MDEV-15982: Incorrect results when subquery is materialized
--echo #
CREATE TABLE `t1` (`id` int(32) NOT NULL primary key);
INSERT INTO `t1` VALUES
(45), (46), (47), (48), (49), (50), (51), (52), (53), (54), (55), (56), (57), (58), (59), (60), (61), (62),
(63), (64), (65), (66), (67), (68), (69), (70), (71), (72), (73), (74), (75), (76), (77), (78), (79), (80),
(81), (82), (83), (84), (85), (86), (87), (88), (89), (90), (91), (92),(93),(94),(95),(96), (97), (98),
(99), (100), (101), (102), (103), (104), (105), (106), (107), (108), (109), (110), (111), (112), (113),
(114), (115), (116), (117), (118), (119), (120), (121), (122), (123), (124), (125), (126), (127), (128),
(129), (130), (131), (132), (133), (134), (135), (136), (137), (138), (139), (140), (141), (142), (143), (144), (145), (146),
(147), (148), (149), (150), (151), (152), (153), (154), (155), (156), (157), (158), (159), (160), (161),
(162), (163), (164), (165), (166), (167), (168), (169), (170), (171), (172), (173),
(174), (175), (176), (177), (178), (179), (180), (181), (182), (183), (2), (3), (4), (5), (6), (19), (35),
(7), (20), (8), (36), (219), (22), (10), (23), (37), (11), (24);
CREATE TABLE `t2` (`type` int , `id` int(32) NOT NULL primary key);
INSERT INTO `t2` VALUES
(2,2),(2,3),(1,4),(2,5),(1,6),(1,19),(5,7),(1,20),(1,8),(1,21),(1,9),
(1,22),(2,10),(1,23),(2,11),(1,24),(1,12),(1,25),(2,13),(2,26),(2,14),
(2,27),(1,15),(1,28),(3,16),(1,29),(2,17),(1,30),(5,18),(2,1);
CREATE TABLE `t3` (`ref_id` int(32) unsigned ,`type` varchar(80),`id` int(32) NOT NULL );
INSERT INTO `t3` VALUES
(1,'incident',31),(2,'faux pas',32),
(5,'oopsies',33),(3,'deniable',34),
(11,'wasntme',35),(10,'wasntme',36),
(17,'faux pas',37),(13,'unlikely',38),
(13,'improbable',39),(14,'incident',40),
(26,'problem',41),(14,'problem',42),
(26,'incident',43),(27,'incident',44);
explain
SELECT t2.id FROM t2,t1
WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
SELECT t2.id FROM t2,t1
WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
set optimizer_switch='materialization=off';
SELECT t2.id FROM t2,t1
WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
set optimizer_switch='materialization=on';
DROP TABLE t1,t2,t3;
--echo #
--echo # MDEV-15247: Crash when SET NAMES 'utf8' is set
--echo #

View file

@ -2157,6 +2157,85 @@ eval $q;
DROP TABLE t1,t2,t3;
set optimizer_switch=@save_optimizer_switch;
--echo #
--echo # MDEV-16751: Server crashes in st_join_table::cleanup or
--echo # TABLE_LIST::is_with_table_recursive_reference with join_cache_level>2
--echo #
set @save_join_cache_level= @@join_cache_level;
set join_cache_level=4;
CREATE TABLE t1 ( id int NOT NULL);
INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL) ;
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);
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
set @@join_cache_level= @save_join_cache_level;
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);
SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
drop table t1,t2;
--echo #
--echo # MDEV-15454: Nested SELECT IN returns wrong results
--echo #
CREATE TABLE t1 ( a int NOT NULL PRIMARY KEY);
CREATE TABLE t2 ( a int, b int );
INSERT INTO t2 VALUES (7878, 96),(3465, 96),(1403, 96),(4189, 96),(8732, 96), (5,96);
CREATE TABLE t3 (c int unsigned NOT NULL, b int unsigned NOT NULL, PRIMARY KEY (c,b));
INSERT INTO t3 (c, b) VALUES (27, 96);
DELIMITER $$;
CREATE PROCEDURE prepare_data()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE i < 1000 DO
INSERT INTO t1 (a) VALUES (i);
INSERT INTO t2 (a,b) VALUES (i,56);
INSERT INTO t3 (c,b) VALUES (i,i);
SET i = i + 1;
END WHILE;
END$$
DELIMITER ;$$
CALL prepare_data();
SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27);
set @save_optimizer_switch= @@optimizer_switch;
SET optimizer_switch='materialization=off';
SELECT t1.a FROM t1
WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
SET optimizer_switch='materialization=on';
SELECT t1.a FROM t1
WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
drop procedure prepare_data;
set @@optimizer_switch= @save_optimizer_switch;
drop table t1,t2,t3;
CREATE TABLE t1 ( id int NOT NULL, key(id));
INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL);
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);
SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
drop table t1,t2;
drop view v1;
--echo # End of 5.5 tests
--echo #
--echo # MDEV-7220: Materialization strategy is not used for REPLACE ... SELECT

View file

@ -1454,6 +1454,21 @@ DROP VIEW v1;
UNION
(SELECT 2, 2);
--echo #
--echo # Bug#27197235 USER VARIABLE + UINON + DECIMAL COLUMN RETURNS
--echo # WRONG VALUES
--echo #
let $old_charset= `SELECT @@character_set_client`;
SET NAMES utf8;
SET @advertAcctId = 1000003;
select @advertAcctId as a from dual union all select 1.0 from dual;
eval SET NAMES $old_charset;
SET @advertAcctId = 1000003;
select @advertAcctId as a from dual union all select 1.0 from dual;
--echo End of 5.5 tests
--echo #

View file

@ -626,6 +626,19 @@
fun:dlopen*
}
#
# Warning caused by small memory leak in _dl_init
#
{
dl_init memory leak
Memcheck:Leak
fun:malloc
obj:*/libstdc++.so*
fun:call_init.part*
fun:_dl_init
}
#
# In glibc (checked version 2.7), inet_ntoa allocates an 18-byte
# per-thread static buffer for the return value. That memory is freed

View file

@ -39,7 +39,10 @@ int my_rename(const char *from, const char *to, myf MyFlags)
if (link(from, to) || unlink(from))
{
#endif
my_errno=errno;
if (errno == ENOENT && !access(from, F_OK))
my_errno= ENOTDIR;
else
my_errno= errno;
error = -1;
if (MyFlags & (MY_FAE+MY_WME))
my_error(EE_LINK, MYF(ME_BELL+ME_WAITTANG),from,to,my_errno);

View file

@ -91,6 +91,7 @@ SET(ADD_GIS_SP_EOL ";")
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/maria_add_gis_sp.sql.in
${CMAKE_CURRENT_BINARY_DIR}/maria_add_gis_sp_bootstrap.sql ESCAPE_QUOTES @ONLY)
IF (NOT WITHOUT_SERVER)
INSTALL(FILES
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables.sql
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables_data.sql
@ -103,6 +104,7 @@ INSTALL(FILES
${FIX_PRIVILEGES_SQL}
DESTINATION ${INSTALL_MYSQLSHAREDIR} COMPONENT Server
)
ENDIF()
# TCMalloc hacks
IF(MALLOC_LIB)

View file

@ -329,7 +329,7 @@ else
$opt->{basedir} = '@prefix@';
$bindir = '@bindir@';
$extra_bindir = $bindir;
$mysqld = '@libexecdir@/mysqld';
$mysqld = '@sbindir@/mysqld';
$srcpkgdatadir = '@pkgdatadir@';
$buildpkgdatadir = '@pkgdatadir@';
$scriptdir = '@scriptdir@';

View file

@ -242,6 +242,11 @@ cannot_find_file()
echo "If you don't want to do a full install, you can use the --srcddir"
echo "option to only install the mysql database and privilege tables"
echo
echo "If you compiled from source, you need to either run 'make install' to"
echo "copy the software into the correct location ready for operation."
echo "If you don't want to do a full install, you can use the --srcdir"
echo "option to only install the mysql database and privilege tables"
echo
echo "If you are using a binary release, you must either be at the top"
echo "level of the extracted archive, or pass the --basedir option"
echo "pointing to that location."
@ -341,7 +346,7 @@ else
basedir="@prefix@"
bindir="@bindir@"
resolveip="$bindir/resolveip"
mysqld="@libexecdir@/mysqld"
mysqld="@sbindir@/mysqld"
srcpkgdatadir="@pkgdatadir@"
buildpkgdatadir="@pkgdatadir@"
plugindir="@pkgplugindir@"

View file

@ -1,5 +1,5 @@
-- Copyright (C) 2003, 2013 Oracle and/or its affiliates.
-- Copyright (C) 2010, 2015 MariaDB Corporation Ab.
-- Copyright (C) 2010, 2018 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
@ -28,15 +28,24 @@ set sql_mode='';
set storage_engine=MyISAM;
set enforce_storage_engine=NULL;
ALTER TABLE user add File_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
ALTER TABLE user add File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
# Detect whether or not we had the Grant_priv column
SET @hadGrantPriv:=0;
SELECT @hadGrantPriv:=1 FROM user WHERE Grant_priv LIKE '%';
ALTER TABLE user add Grant_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
ALTER TABLE host add Grant_priv enum('N','Y') NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
ALTER TABLE db add Grant_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add References_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Index_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL,add Alter_priv enum('N','Y') COLLATE utf8_general_ci NOT NULL;
ALTER TABLE user add Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
add References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
add Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
add Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
ALTER TABLE host add Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
add References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
add Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
add Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
ALTER TABLE db add Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
add References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
add Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
add Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
# Fix privileges for old tables
UPDATE user SET Grant_priv=File_priv,References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Create_priv WHERE @hadGrantPriv = 0;
@ -48,11 +57,11 @@ UPDATE host SET References_priv=Create_priv,Index_priv=Create_priv,Alter_priv=Cr
# Adding columns needed by GRANT .. REQUIRE (openssl)
ALTER TABLE user
ADD ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci NOT NULL,
ADD ssl_type enum('','ANY','X509', 'SPECIFIED') DEFAULT '' NOT NULL,
ADD ssl_cipher BLOB NOT NULL,
ADD x509_issuer BLOB NOT NULL,
ADD x509_subject BLOB NOT NULL;
ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL;
ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') DEFAULT '' NOT NULL;
#
# tables_priv
@ -63,9 +72,9 @@ ALTER TABLE tables_priv
ALTER TABLE tables_priv
MODIFY Host char(60) NOT NULL default '',
MODIFY Db char(64) NOT NULL default '',
MODIFY User char(80) NOT NULL default '',
MODIFY User char(80) binary NOT NULL default '',
MODIFY Table_name char(64) NOT NULL default '',
MODIFY Grantor char(141) NOT NULL default '',
MODIFY Grantor char(141) COLLATE utf8_bin NOT NULL default '',
ENGINE=MyISAM,
CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
@ -91,7 +100,7 @@ ALTER TABLE columns_priv
ALTER TABLE columns_priv
MODIFY Host char(60) NOT NULL default '',
MODIFY Db char(64) NOT NULL default '',
MODIFY User char(80) NOT NULL default '',
MODIFY User char(80) binary NOT NULL default '',
MODIFY Table_name char(64) NOT NULL default '',
MODIFY Column_name char(64) NOT NULL default '',
ENGINE=MyISAM,
@ -162,7 +171,7 @@ alter table func comment='User defined functions';
# and reset all char columns to correct width
ALTER TABLE user
MODIFY Host char(60) NOT NULL default '',
MODIFY User char(80) NOT NULL default '',
MODIFY User char(80) binary NOT NULL default '',
ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
# In MySQL 5.7.6 the Password column is removed. Recreate it to preserve the number
@ -198,7 +207,7 @@ ALTER TABLE user
ALTER TABLE db
MODIFY Host char(60) NOT NULL default '',
MODIFY Db char(64) NOT NULL default '',
MODIFY User char(80) NOT NULL default '',
MODIFY User char(80) binary NOT NULL default '',
ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
ALTER TABLE db
MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
@ -460,7 +469,7 @@ ALTER TABLE proc MODIFY db
MODIFY definer
char(141) collate utf8_bin DEFAULT '' NOT NULL,
MODIFY comment
char(64) collate utf8_bin DEFAULT '' NOT NULL;
text collate utf8_bin NOT NULL;
ALTER TABLE proc ADD character_set_client
char(32) collate utf8_bin DEFAULT NULL
@ -524,19 +533,18 @@ ALTER TABLE proc MODIFY comment
SET @hadEventPriv := 0;
SELECT @hadEventPriv :=1 FROM user WHERE Event_priv LIKE '%';
ALTER TABLE user add Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL AFTER Create_user_priv;
ALTER TABLE user ADD Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL AFTER Create_user_priv;
ALTER TABLE user MODIFY Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL AFTER Create_user_priv;
UPDATE user SET Event_priv=Super_priv WHERE @hadEventPriv = 0;
ALTER TABLE db add Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL;
ALTER TABLE db ADD Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL;
ALTER TABLE db MODIFY Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL;
#
# EVENT table
#
ALTER TABLE event DROP PRIMARY KEY;
ALTER TABLE event ADD PRIMARY KEY(db, name);
ALTER TABLE event DROP PRIMARY KEY, ADD PRIMARY KEY(db, name);
# Add sql_mode column just in case.
ALTER TABLE event ADD sql_mode set ('IGNORE_BAD_TABLE_OPTIONS') AFTER on_completion;
# Update list of sql_mode values.
@ -576,8 +584,8 @@ ALTER TABLE event MODIFY sql_mode
) DEFAULT '' NOT NULL AFTER on_completion;
ALTER TABLE event MODIFY name char(64) CHARACTER SET utf8 NOT NULL default '';
ALTER TABLE event MODIFY COLUMN originator INT UNSIGNED NOT NULL;
ALTER TABLE event ADD COLUMN originator INT UNSIGNED NOT NULL AFTER comment;
ALTER TABLE event MODIFY COLUMN originator INT UNSIGNED NOT NULL;
ALTER TABLE event MODIFY COLUMN status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED';
@ -639,12 +647,14 @@ ALTER TABLE user MODIFY Create_tablespace_priv enum('N','Y') COLLATE utf8_genera
UPDATE user SET Create_tablespace_priv = Super_priv WHERE @hadCreateTablespacePriv = 0;
ALTER TABLE user ADD plugin char(64) DEFAULT '', ADD authentication_string TEXT;
ALTER TABLE user ADD plugin char(64) CHARACTER SET latin1 DEFAULT '' NOT NULL,
ADD authentication_string TEXT NOT NULL;
ALTER TABLE user MODIFY plugin char(64) CHARACTER SET latin1 DEFAULT '' NOT NULL,
MODIFY authentication_string TEXT NOT NULL;
ALTER TABLE user ADD password_expired ENUM('N', 'Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
ALTER TABLE user ADD is_role enum('N', 'Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;
ALTER TABLE user ADD default_role char(80) binary DEFAULT '' NOT NULL;
ALTER TABLE user ADD max_statement_time decimal(12,6) DEFAULT 0 NOT NULL;
ALTER TABLE user MODIFY plugin char(64) CHARACTER SET latin1 DEFAULT '' NOT NULL, MODIFY authentication_string TEXT NOT NULL;
-- Somewhere above, we ran ALTER TABLE user .... CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin.
-- we want password_expired column to have collation utf8_general_ci.
ALTER TABLE user MODIFY password_expired ENUM('N', 'Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL;

View file

@ -30,7 +30,7 @@ $opt_example = 0;
$opt_help = 0;
$opt_log = undef();
$opt_mysqladmin = "@bindir@/mysqladmin";
$opt_mysqld = "@libexecdir@/mysqld";
$opt_mysqld = "@sbindir@/mysqld";
$opt_no_log = 0;
$opt_password = undef();
$opt_tcp_ip = 0;

View file

@ -33,7 +33,6 @@ ssystag=""
XTRABACKUP_PID=""
SST_PORT=""
REMOTEIP=""
REMOTEHOST=""
tcert=""
tpem=""
tkey=""
@ -225,7 +224,7 @@ get_transfer()
tcmd="socat -u openssl-listen:${TSST_PORT},reuseaddr,cert=${tpem},cafile=${tcert}${sockopt} stdio"
else
wsrep_log_info "Encrypting with cert=${tpem}, cafile=${tcert}"
tcmd="socat -u stdio openssl-connect:${REMOTEHOST}:${TSST_PORT},cert=${tpem},cafile=${tcert}${sockopt}"
tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},cafile=${tcert}${sockopt}"
fi
elif [[ $encrypt -eq 3 ]];then
wsrep_log_info "Using openssl based encryption with socat: with key and crt"
@ -248,7 +247,7 @@ get_transfer()
tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},key=${tkey},verify=0${sockopt}"
else
wsrep_log_info "Encrypting with cert=${tpem}, key=${tkey}, cafile=${tcert}"
tcmd="socat -u stdio openssl-connect:${REMOTEHOST}:${TSST_PORT},cert=${tpem},key=${tkey},cafile=${tcert}${sockopt}"
tcmd="socat -u stdio openssl-connect:${REMOTEIP}:${TSST_PORT},cert=${tpem},key=${tkey},cafile=${tcert}${sockopt}"
fi
fi
@ -518,10 +517,6 @@ setup_ports()
if [[ "$WSREP_SST_OPT_ROLE" == "donor" ]];then
SST_PORT=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $2 }')
REMOTEIP=$(echo $WSREP_SST_OPT_ADDR | awk -F ':' '{ print $1 }')
REMOTEHOST=$(getent hosts $REMOTEIP | awk '{ print $2 }')
if [[ -z $REMOTEHOST ]];then
REMOTEHOST=$REMOTEIP
fi
lsn=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $4 }')
sst_ver=$(echo $WSREP_SST_OPT_ADDR | awk -F '[:/]' '{ print $5 }')
else
@ -644,6 +639,27 @@ send_donor()
}
monitor_process()
{
local sst_stream_pid=$1
while true ; do
if ! ps --pid "${WSREP_SST_OPT_PARENT}" &>/dev/null; then
wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
kill -- -"${WSREP_SST_OPT_PARENT}"
exit 32
fi
if ! ps --pid "${sst_stream_pid}" &>/dev/null; then
break
fi
sleep 0.1
done
}
if [[ ! -x `which $INNOBACKUPEX_BIN` ]];then
wsrep_log_error "${INNOBACKUPEX_BIN} not in path: $PATH"
exit 2
@ -932,7 +948,7 @@ then
MAGIC_FILE="${DATA}/${INFO_FILE}"
wsrep_log_info "Waiting for SST streaming to complete!"
wait $jpid
monitor_process $jpid
get_proc

View file

@ -374,6 +374,8 @@ EOF
then
wsrep_log_error \
"Parent mysqld process (PID:$MYSQLD_PID) terminated unexpectedly."
kill -- -"${MYSQLD_PID}"
sleep 1
exit 32
fi

View file

@ -801,6 +801,27 @@ check_for_version()
fi
}
monitor_process()
{
local sst_stream_pid=$1
while true ; do
if ! ps --pid "${WSREP_SST_OPT_PARENT}" &>/dev/null; then
wsrep_log_error "Parent mysqld process (PID:${WSREP_SST_OPT_PARENT}) terminated unexpectedly."
kill -- -"${WSREP_SST_OPT_PARENT}"
exit 32
fi
if ! ps --pid "${sst_stream_pid}" &>/dev/null; then
break
fi
sleep 0.1
done
}
if [[ ! -x `which $INNOBACKUPEX_BIN` ]];then
wsrep_log_error "innobackupex not in path: $PATH"
@ -1102,7 +1123,7 @@ then
MAGIC_FILE="${DATA}/${INFO_FILE}"
wsrep_log_info "Waiting for SST streaming to complete!"
wait $jpid
monitor_process $jpid
get_proc

View file

@ -1465,6 +1465,7 @@ MYSQL_DATA *cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
if ((pkt_len= cli_safe_read(mysql)) == packet_error)
DBUG_RETURN(0);
if (pkt_len == 0) DBUG_RETURN(0);
if (!(result=(MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA),
MYF(MY_WME | MY_ZEROFILL))))
{
@ -2583,6 +2584,9 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
enum enum_ssl_init_error ssl_init_error;
const char *cert_error;
unsigned long ssl_error;
#ifdef EMBEDDED_LIBRARY
DBUG_ASSERT(0); // embedded should not do SSL connect
#endif
/*
Send mysql->client_flag, max_packet_size - unencrypted otherwise

View file

@ -7978,7 +7978,13 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
return 0;
}
if (table->blob_storage) // GROUP_CONCAT with ORDER BY | DISTINCT
/*
For min/max fields of statistical data 'table' is set to NULL.
It could not be otherwise as this data is shared by many instances
of the same base table.
*/
if (table && table->blob_storage) // GROUP_CONCAT with ORDER BY | DISTINCT
{
DBUG_ASSERT(!f_is_hex_escape(flags));
DBUG_ASSERT(field_charset == cs);

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2000, 2018, Oracle and/or its affiliates.
Copyright (c) 2010, 2018, MariaDB Corporation
This program is free software; you can redistribute it and/or modify
@ -10408,6 +10408,7 @@ bool Item_type_holder::join_types(THD *thd, Item *item)
if (Field::result_merge_type(real_field_type()) == DECIMAL_RESULT)
{
collation.set_numeric();
decimals= MY_MIN(MY_MAX(decimals, item->decimals), DECIMAL_MAX_SCALE);
int item_int_part= item->decimal_int_part();
int item_prec = MY_MAX(prev_decimal_int_part, item_int_part) + decimals;

View file

@ -1518,32 +1518,18 @@ String *Item_str_conv::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
String *res;
if (!(res=args[0]->val_str(str)))
{
null_value=1; /* purecov: inspected */
return 0; /* purecov: inspected */
}
null_value=0;
if (multiply == 1)
{
uint len;
res= copy_if_not_alloced(&tmp_value, res, res->length());
len= converter(collation.collation, (char*) res->ptr(), res->length(),
(char*) res->ptr(), res->length());
DBUG_ASSERT(len <= res->length());
res->length(len);
}
else
{
uint len= res->length() * multiply;
tmp_value.alloc(len);
tmp_value.set_charset(collation.collation);
len= converter(collation.collation, (char*) res->ptr(), res->length(),
(char*) tmp_value.ptr(), len);
tmp_value.length(len);
res= &tmp_value;
}
return res;
uint alloced_length, len;
if ((null_value= (!(res= args[0]->val_str(&tmp_value)) ||
str->alloc((alloced_length= res->length() * multiply)))))
return 0;
len= converter(collation.collation, (char*) res->ptr(), res->length(),
(char*) str->ptr(), alloced_length);
DBUG_ASSERT(len <= alloced_length);
str->set_charset(collation.collation);
str->length(len);
return str;
}
@ -1746,7 +1732,7 @@ String *Item_func_substr_index::val_str(String *str)
DBUG_ASSERT(fixed == 1);
char buff[MAX_FIELD_WIDTH];
String tmp(buff,sizeof(buff),system_charset_info);
String *res= args[0]->val_str(str);
String *res= args[0]->val_str(&tmp_value);
String *delimiter= args[1]->val_str(&tmp);
int32 count= (int32) args[2]->val_int();
uint offset;
@ -1795,20 +1781,31 @@ String *Item_func_substr_index::val_str(String *str)
if (pass == 0) /* count<0 */
{
c+=n+1;
if (c<=0) return res; /* not found, return original string */
if (c<=0)
{
str->copy(res->ptr(), res->length(), collation.collation);
return str; // not found, return the original string
}
ptr=res->ptr();
}
else
{
if (c) return res; /* Not found, return original string */
if (c)
{
str->copy(res->ptr(), res->length(), collation.collation);
return str; // not found, return the original string
}
if (count>0) /* return left part */
{
tmp_value.set(*res,0,(ulong) (ptr-res->ptr()));
str->copy(res->ptr(), (uint32) (ptr-res->ptr()), collation.collation);
return str;
}
else /* return right part */
{
ptr+= delimiter_length;
tmp_value.set(*res,(ulong) (ptr-res->ptr()), (ulong) (strend-ptr));
ptr+= delimiter_length;
str->copy(res->ptr() + (ptr-res->ptr()), (uint32) (strend - ptr),
collation.collation);
return str;
}
}
}
@ -1820,13 +1817,16 @@ String *Item_func_substr_index::val_str(String *str)
{ // start counting from the beginning
for (offset=0; ; offset+= delimiter_length)
{
if ((int) (offset= res->strstr(*delimiter, offset)) < 0)
return res; // Didn't find, return org string
if (!--count)
{
tmp_value.set(*res,0,offset);
break;
}
if ((int) (offset= res->strstr(*delimiter, offset)) < 0)
{
str->copy(res->ptr(), res->length(), collation.collation);
return str; // not found, return the original string
}
if (!--count)
{
str->copy(res->ptr(), offset, collation.collation);
return str;
}
}
}
else
@ -1841,30 +1841,32 @@ String *Item_func_substr_index::val_str(String *str)
address space less than where the found substring is located
in res
*/
if ((int) (offset= res->strrstr(*delimiter, offset)) < 0)
return res; // Didn't find, return org string
if ((int) (offset= res->strrstr(*delimiter, offset)) < 0)
{
str->copy(res->ptr(), res->length(), collation.collation);
return str; // not found, return the original string
}
/*
At this point, we've searched for the substring
the number of times as supplied by the index value
*/
if (!++count)
{
offset+= delimiter_length;
tmp_value.set(*res,offset,res->length()- offset);
break;
}
if (!++count)
{
offset+= delimiter_length;
str->copy(res->ptr() + offset, res->length() - offset,
collation.collation);
return str;
}
}
if (count)
return res; // Didn't find, return org string
{
str->copy(res->ptr(), res->length(), collation.collation);
return str; // not found, return the original string
}
}
}
/*
We always mark tmp_value as const so that if val_str() is called again
on this object, we don't disrupt the contents of tmp_value when it was
derived from another String.
*/
tmp_value.mark_as_const();
return (&tmp_value);
DBUG_ASSERT(0);
return NULL;
}
/*

View file

@ -2708,14 +2708,14 @@ void MYSQL_LOG::close(uint exiting)
if (log_type == LOG_BIN && mysql_file_sync(log_file.file, MYF(MY_WME)) && ! write_error)
{
write_error= 1;
sql_print_error(ER_THD_OR_DEFAULT(current_thd, ER_ERROR_ON_WRITE), name, errno);
sql_print_error(ER_DEFAULT(ER_ERROR_ON_WRITE), name, errno);
}
if (!(exiting & LOG_CLOSE_DELAYED_CLOSE) &&
mysql_file_close(log_file.file, MYF(MY_WME)) && ! write_error)
{
write_error= 1;
sql_print_error(ER_THD_OR_DEFAULT(current_thd, ER_ERROR_ON_WRITE), name, errno);
sql_print_error(ER_DEFAULT(ER_ERROR_ON_WRITE), name, errno);
}
}
@ -2900,7 +2900,7 @@ err:
if (!write_error)
{
write_error= 1;
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
sql_print_error(ER_DEFAULT(ER_ERROR_ON_WRITE), name, errno);
}
mysql_mutex_unlock(&LOCK_log);
return TRUE;
@ -3086,7 +3086,7 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time,
if (! write_error)
{
write_error= 1;
sql_print_error(ER_THD(thd, ER_ERROR_ON_WRITE), name, tmp_errno);
sql_print_error(ER_DEFAULT(ER_ERROR_ON_WRITE), name, tmp_errno);
}
}
}
@ -8425,8 +8425,7 @@ void MYSQL_BIN_LOG::close(uint exiting)
if (mysql_file_close(index_file.file, MYF(0)) < 0 && ! write_error)
{
write_error= 1;
sql_print_error(ER_THD_OR_DEFAULT(current_thd, ER_ERROR_ON_WRITE),
index_file_name, errno);
sql_print_error(ER_DEFAULT(ER_ERROR_ON_WRITE), index_file_name, errno);
}
}
log_state= (exiting & LOG_CLOSE_TO_BE_OPENED) ? LOG_TO_BE_OPENED : LOG_CLOSED;

View file

@ -489,7 +489,7 @@ my_bool opt_master_verify_checksum= 0;
my_bool opt_slave_sql_verify_checksum= 1;
const char *binlog_format_names[]= {"MIXED", "STATEMENT", "ROW", NullS};
volatile sig_atomic_t calling_initgroups= 0; /**< Used in SIGSEGV handler. */
uint mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options;
uint mysqld_port, select_errors, dropping_tables, ha_open_options;
uint mysqld_extra_port;
uint mysqld_port_timeout;
ulong delay_key_write_options;
@ -516,6 +516,7 @@ ulonglong max_binlog_cache_size=0;
ulong slave_max_allowed_packet= 0;
ulonglong binlog_stmt_cache_size=0;
ulonglong max_binlog_stmt_cache_size=0;
ulonglong test_flags;
ulonglong query_cache_size=0;
ulong query_cache_limit=0;
ulong executed_events=0;
@ -5648,6 +5649,11 @@ int win_main(int argc, char **argv)
int mysqld_main(int argc, char **argv)
#endif
{
#ifndef _WIN32
/* We can't close stdin just now, because it may be booststrap mode. */
bool please_close_stdin= fcntl(STDIN_FILENO, F_GETFD) >= 0;
#endif
/*
Perform basic thread library and malloc initialization,
to be able to read defaults files and parse options.
@ -6045,7 +6051,7 @@ int mysqld_main(int argc, char **argv)
#ifndef _WIN32
// try to keep fd=0 busy
if (!freopen("/dev/null", "r", stdin))
if (please_close_stdin && !freopen("/dev/null", "r", stdin))
{
// fall back on failure
fclose(stdin);

View file

@ -166,7 +166,8 @@ extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size;
extern ulong tc_log_page_waits;
extern my_bool relay_log_purge, opt_innodb_safe_binlog, opt_innodb;
extern my_bool relay_log_recovery;
extern uint test_flags,select_errors,ha_open_options;
extern uint select_errors,ha_open_options;
extern ulonglong test_flags;
extern uint protocol_version, mysqld_port, dropping_tables;
extern ulong delay_key_write_options;
extern char *opt_logname, *opt_slow_logname, *opt_bin_logname,

View file

@ -441,6 +441,7 @@ bool subquery_types_allow_materialization(Item_in_subselect *in_subs);
static bool replace_where_subcondition(JOIN *, Item **, Item *, Item *, bool);
static int subq_sj_candidate_cmp(Item_in_subselect* el1, Item_in_subselect* el2,
void *arg);
static void reset_equality_number_for_subq_conds(Item * cond);
static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred);
static bool convert_subq_to_jtbm(JOIN *parent_join,
Item_in_subselect *subq_pred, bool *remove);
@ -819,6 +820,9 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
details)
* require that compared columns have exactly the same type. This is
a temporary measure to avoid BUG#36752-type problems.
JOIN_TAB::keyuse_is_valid_for_access_in_chosen_plan expects that for Semi Join Materialization
Scan all the items in the select list of the IN Subquery are of the type Item::FIELD_ITEM.
*/
static
@ -1456,6 +1460,67 @@ static int subq_sj_candidate_cmp(Item_in_subselect* el1, Item_in_subselect* el2,
}
/**
@brief
reset the value of the field in_eqaulity_no for all Item_func_eq
items in the where clause of the subquery.
Look for in_equality_no description in Item_func_eq class
DESCRIPTION
Lets have an example:
SELECT t1.a FROM t1 WHERE t1.a IN
(SELECT t2.a FROM t2 where t2.b IN
(select t3.b from t3 where t3.c=27 ))
So for such a query we have the parent, child and
grandchild select.
So for the equality t2.b = t3.b we set the value for in_equality_no to
0 according to its description. Wewe do the same for t1.a = t2.a.
But when we look at the child select (with the grandchild select merged),
the query would be
SELECT t1.a FROM t1 WHERE t1.a IN
(SELECT t2.a FROM t2 where t2.b = t3.b and t3.c=27)
and then when the child select is merged into the parent select the query
would look like
SELECT t1.a FROM t1, semi-join-nest(t2,t3)
WHERE t1.a =t2.a and t2.b = t3.b and t3.c=27
Still we would have in_equality_no set for t2.b = t3.b
though it does not take part in the semi-join equality for the parent select,
so we should reset its value to UINT_MAX.
@param cond WHERE clause of the subquery
*/
static void reset_equality_number_for_subq_conds(Item * cond)
{
if (!cond)
return;
if (cond->type() == Item::COND_ITEM)
{
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
Item *item;
while ((item=li++))
{
if (item->type() == Item::FUNC_ITEM &&
((Item_func*)item)->functype()== Item_func::EQ_FUNC)
((Item_func_eq*)item)->in_equality_no= UINT_MAX;
}
}
else
{
if (cond->type() == Item::FUNC_ITEM &&
((Item_func*)cond)->functype()== Item_func::EQ_FUNC)
((Item_func_eq*)cond)->in_equality_no= UINT_MAX;
}
return;
}
/*
Convert a subquery predicate into a TABLE_LIST semi-join nest
@ -1719,6 +1784,7 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred)
*/
sj_nest->sj_in_exprs= subq_pred->left_expr->cols();
sj_nest->nested_join->sj_outer_expr_list.empty();
reset_equality_number_for_subq_conds(sj_nest->sj_on_expr);
if (subq_pred->left_expr->cols() == 1)
{
@ -3543,7 +3609,8 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
first= tablenr - sjm->tables + 1;
join->best_positions[first].n_sj_tables= sjm->tables;
join->best_positions[first].sj_strategy= SJ_OPT_MATERIALIZE;
join->sjm_lookup_tables|= s->table->map;
for (uint i= first; i < first+ sjm->tables; i++)
join->sjm_lookup_tables |= join->best_positions[i].table->table->map;
}
else if (pos->sj_strategy == SJ_OPT_MATERIALIZE_SCAN)
{

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