mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
Merge tag 'mariadb-5.5.57' into 5.5-galera
This commit is contained in:
@@ -149,7 +149,7 @@ static my_bool ignore_errors=0,wait_flag=0,quick=0,
|
||||
default_pager_set= 0, opt_sigint_ignore= 0,
|
||||
auto_vertical_output= 0,
|
||||
show_warnings= 0, executing_query= 0,
|
||||
ignore_spaces= 0, opt_progress_reports;
|
||||
ignore_spaces= 0, opt_binhex= 0, opt_progress_reports;
|
||||
static my_bool debug_info_flag, debug_check_flag, batch_abort_on_error;
|
||||
static my_bool column_types_flag;
|
||||
static my_bool preserve_comments= 0;
|
||||
@@ -1460,6 +1460,8 @@ static struct my_option my_long_options[] =
|
||||
{"batch", 'B',
|
||||
"Don't use history file. Disable interactive behavior. (Enables --silent.)",
|
||||
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"binary-as-hex", 'b', "Print binary data as hex", &opt_binhex, &opt_binhex,
|
||||
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"character-sets-dir", OPT_CHARSETS_DIR,
|
||||
"Directory for character set files.", &charsets_dir,
|
||||
&charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
@@ -2287,8 +2289,10 @@ static bool add_line(String &buffer, char *line, ulong line_length,
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (!*ml_comment && inchar == '\\' &&
|
||||
!(*in_string &&
|
||||
if (!*ml_comment && inchar == '\\' && *in_string != '`' &&
|
||||
!(*in_string == '"' &&
|
||||
(mysql.server_status & SERVER_STATUS_ANSI_QUOTES)) &&
|
||||
!(*in_string &&
|
||||
(mysql.server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)))
|
||||
{
|
||||
// Found possbile one character command like \c
|
||||
@@ -2850,7 +2854,7 @@ You can turn off this feature to get a quicker startup with -A\n\n");
|
||||
mysql_free_result(fields);
|
||||
break;
|
||||
}
|
||||
field_names[i][num_fields*2]= '\0';
|
||||
field_names[i][num_fields*2]= NULL;
|
||||
j=0;
|
||||
while ((sql_field=mysql_fetch_field(fields)))
|
||||
{
|
||||
@@ -3283,7 +3287,8 @@ com_go(String *buffer,char *line __attribute__((unused)))
|
||||
print_table_data_html(result);
|
||||
else if (opt_xml)
|
||||
print_table_data_xml(result);
|
||||
else if (vertical || (auto_vertical_output && (terminal_width < get_result_width(result))))
|
||||
else if (vertical || (auto_vertical_output &&
|
||||
(terminal_width < get_result_width(result))))
|
||||
print_table_data_vertically(result);
|
||||
else if (opt_silent && verbose <= 2 && !output_tables)
|
||||
print_tab_data(result);
|
||||
@@ -3502,6 +3507,41 @@ print_field_types(MYSQL_RES *result)
|
||||
}
|
||||
|
||||
|
||||
/* Used to determine if we should invoke print_as_hex for this field */
|
||||
|
||||
static bool
|
||||
is_binary_field(MYSQL_FIELD *field)
|
||||
{
|
||||
if ((field->charsetnr == 63) &&
|
||||
(field->type == MYSQL_TYPE_BIT ||
|
||||
field->type == MYSQL_TYPE_BLOB ||
|
||||
field->type == MYSQL_TYPE_LONG_BLOB ||
|
||||
field->type == MYSQL_TYPE_MEDIUM_BLOB ||
|
||||
field->type == MYSQL_TYPE_TINY_BLOB ||
|
||||
field->type == MYSQL_TYPE_VAR_STRING ||
|
||||
field->type == MYSQL_TYPE_STRING ||
|
||||
field->type == MYSQL_TYPE_VARCHAR ||
|
||||
field->type == MYSQL_TYPE_GEOMETRY))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Print binary value as hex literal (0x ...) */
|
||||
|
||||
static void
|
||||
print_as_hex(FILE *output_file, const char *str, ulong len, ulong total_bytes_to_send)
|
||||
{
|
||||
const char *ptr= str, *end= ptr+len;
|
||||
ulong i;
|
||||
fprintf(output_file, "0x");
|
||||
for(; ptr < end; ptr++)
|
||||
fprintf(output_file, "%02X", *((uchar*)ptr));
|
||||
for (i= 2*len+2; i < total_bytes_to_send; i++)
|
||||
tee_putc((int)' ', output_file);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_table_data(MYSQL_RES *result)
|
||||
{
|
||||
@@ -3528,6 +3568,8 @@ print_table_data(MYSQL_RES *result)
|
||||
length=max(length,field->max_length);
|
||||
if (length < 4 && !IS_NOT_NULL(field->flags))
|
||||
length=4; // Room for "NULL"
|
||||
if (opt_binhex && is_binary_field(field))
|
||||
length= 2 + length * 2;
|
||||
field->max_length=length;
|
||||
num_flag[mysql_field_tell(result) - 1]= IS_NUM(field->type);
|
||||
separator.fill(separator.length()+length+2,'-');
|
||||
@@ -3595,9 +3637,11 @@ print_table_data(MYSQL_RES *result)
|
||||
many extra padding-characters we should send with the printing function.
|
||||
*/
|
||||
visible_length= charset_info->cset->numcells(charset_info, buffer, buffer + data_length);
|
||||
extra_padding= data_length - visible_length;
|
||||
extra_padding= (uint) (data_length - visible_length);
|
||||
|
||||
if (field_max_length > MAX_COLUMN_LENGTH)
|
||||
if (opt_binhex && is_binary_field(field))
|
||||
print_as_hex(PAGER, cur[off], lengths[off], field_max_length);
|
||||
else if (field_max_length > MAX_COLUMN_LENGTH)
|
||||
tee_print_sized_data(buffer, data_length, MAX_COLUMN_LENGTH+extra_padding, FALSE);
|
||||
else
|
||||
{
|
||||
@@ -3730,11 +3774,15 @@ print_table_data_html(MYSQL_RES *result)
|
||||
if (interrupted_query)
|
||||
break;
|
||||
ulong *lengths=mysql_fetch_lengths(result);
|
||||
field= mysql_fetch_fields(result);
|
||||
(void) tee_fputs("<TR>", PAGER);
|
||||
for (uint i=0; i < mysql_num_fields(result); i++)
|
||||
{
|
||||
(void) tee_fputs("<TD>", PAGER);
|
||||
xmlencode_print(cur[i], lengths[i]);
|
||||
if (opt_binhex && is_binary_field(&field[i]))
|
||||
print_as_hex(PAGER, cur[i], lengths[i], lengths[i]);
|
||||
else
|
||||
xmlencode_print(cur[i], lengths[i]);
|
||||
(void) tee_fputs("</TD>", PAGER);
|
||||
}
|
||||
(void) tee_fputs("</TR>", PAGER);
|
||||
@@ -3770,7 +3818,10 @@ print_table_data_xml(MYSQL_RES *result)
|
||||
if (cur[i])
|
||||
{
|
||||
tee_fprintf(PAGER, "\">");
|
||||
xmlencode_print(cur[i], lengths[i]);
|
||||
if (opt_binhex && is_binary_field(&fields[i]))
|
||||
print_as_hex(PAGER, cur[i], lengths[i], lengths[i]);
|
||||
else
|
||||
xmlencode_print(cur[i], lengths[i]);
|
||||
tee_fprintf(PAGER, "</field>\n");
|
||||
}
|
||||
else
|
||||
@@ -3817,23 +3868,28 @@ print_table_data_vertically(MYSQL_RES *result)
|
||||
{
|
||||
unsigned int i;
|
||||
const char *p;
|
||||
|
||||
if (opt_binhex && is_binary_field(field))
|
||||
fprintf(PAGER, "0x");
|
||||
for (i= 0, p= cur[off]; i < lengths[off]; i+= 1, p+= 1)
|
||||
{
|
||||
if (*p == '\0')
|
||||
tee_putc((int)' ', PAGER);
|
||||
if (opt_binhex && is_binary_field(field))
|
||||
fprintf(PAGER, "%02X", *((uchar*)p));
|
||||
else
|
||||
tee_putc((int)*p, PAGER);
|
||||
{
|
||||
if (*p == '\0')
|
||||
tee_putc((int)' ', PAGER);
|
||||
else
|
||||
tee_putc((int)*p, PAGER);
|
||||
}
|
||||
}
|
||||
tee_putc('\n', PAGER);
|
||||
}
|
||||
else
|
||||
else
|
||||
tee_fprintf(PAGER, "NULL\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* print_warnings should be called right after executing a statement */
|
||||
|
||||
static void print_warnings()
|
||||
@@ -3970,11 +4026,19 @@ print_tab_data(MYSQL_RES *result)
|
||||
while ((cur = mysql_fetch_row(result)))
|
||||
{
|
||||
lengths=mysql_fetch_lengths(result);
|
||||
safe_put_field(cur[0],lengths[0]);
|
||||
field= mysql_fetch_fields(result);
|
||||
if (opt_binhex && is_binary_field(&field[0]))
|
||||
print_as_hex(PAGER, cur[0], lengths[0], lengths[0]);
|
||||
else
|
||||
safe_put_field(cur[0],lengths[0]);
|
||||
|
||||
for (uint off=1 ; off < mysql_num_fields(result); off++)
|
||||
{
|
||||
(void) tee_fputs("\t", PAGER);
|
||||
safe_put_field(cur[off], lengths[off]);
|
||||
if (opt_binhex && field && is_binary_field(&field[off]))
|
||||
print_as_hex(PAGER, cur[off], lengths[off], lengths[off]);
|
||||
else
|
||||
safe_put_field(cur[off], lengths[off]);
|
||||
}
|
||||
(void) tee_fputs("\n", PAGER);
|
||||
}
|
||||
|
||||
@@ -1698,12 +1698,22 @@ int cat_file(DYNAMIC_STRING* ds, const char* filename)
|
||||
{
|
||||
int fd;
|
||||
size_t len;
|
||||
char buff[16384];
|
||||
char *buff;
|
||||
|
||||
if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0)
|
||||
return 1;
|
||||
while((len= my_read(fd, (uchar*)&buff,
|
||||
sizeof(buff)-1, MYF(0))) > 0)
|
||||
|
||||
len= (size_t) my_seek(fd, 0, SEEK_END, MYF(0));
|
||||
my_seek(fd, 0, SEEK_SET, MYF(0));
|
||||
if (len == (size_t)MY_FILEPOS_ERROR ||
|
||||
!(buff= (char*)my_malloc(len + 1, MYF(0))))
|
||||
{
|
||||
my_close(fd, MYF(0));
|
||||
return 1;
|
||||
}
|
||||
len= my_read(fd, (uchar*)buff, len, MYF(0));
|
||||
my_close(fd, MYF(0));
|
||||
|
||||
{
|
||||
char *p= buff, *start= buff,*end=buff+len;
|
||||
while (p < end)
|
||||
@@ -1726,7 +1736,7 @@ int cat_file(DYNAMIC_STRING* ds, const char* filename)
|
||||
*p= 0;
|
||||
replace_dynstr_append_mem(ds, start, p-start);
|
||||
}
|
||||
my_close(fd, MYF(0));
|
||||
my_free(buff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -6476,6 +6486,16 @@ my_bool end_of_query(int c)
|
||||
}
|
||||
|
||||
|
||||
static inline bool is_escape_char(char c, char in_string)
|
||||
{
|
||||
if (c != '\\' || in_string == '`') return false;
|
||||
if (!cur_con) return true;
|
||||
uint server_status= cur_con->mysql->server_status;
|
||||
if (server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES) return false;
|
||||
return !(server_status & SERVER_STATUS_ANSI_QUOTES && in_string == '"');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Read one "line" from the file
|
||||
|
||||
@@ -6502,7 +6522,7 @@ my_bool end_of_query(int c)
|
||||
|
||||
int read_line(char *buf, int size)
|
||||
{
|
||||
char c, UNINIT_VAR(last_quote), last_char= 0;
|
||||
char c, last_quote=0, last_char= 0;
|
||||
char *p= buf, *buf_end= buf + size - 1;
|
||||
int skip_char= 0;
|
||||
my_bool have_slash= FALSE;
|
||||
@@ -6584,7 +6604,7 @@ int read_line(char *buf, int size)
|
||||
state= R_Q;
|
||||
}
|
||||
}
|
||||
have_slash= (c == '\\');
|
||||
have_slash= is_escape_char(c, last_quote);
|
||||
break;
|
||||
|
||||
case R_COMMENT:
|
||||
@@ -6654,7 +6674,7 @@ int read_line(char *buf, int size)
|
||||
case R_Q:
|
||||
if (c == last_quote)
|
||||
state= R_NORMAL;
|
||||
else if (c == '\\')
|
||||
else if (is_escape_char(c, last_quote))
|
||||
state= R_SLASH_IN_Q;
|
||||
break;
|
||||
|
||||
|
||||
@@ -25,7 +25,12 @@ SET(CPACK_COMPONENT_COMPAT_GROUP "compat")
|
||||
SET(CPACK_COMPONENTS_ALL Server ManPagesServer IniFiles Server_Scripts
|
||||
SupportFiles Readme Test)
|
||||
SET(CPACK_RPM_PACKAGE_NAME "MariaDB-Galera")
|
||||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${VERSION}-${RPM}-${CMAKE_SYSTEM_PROCESSOR}")
|
||||
IF(CMAKE_VERSION VERSION_LESS "3.6.0")
|
||||
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${VERSION}-${RPM}-${CMAKE_SYSTEM_PROCESSOR}")
|
||||
ELSE()
|
||||
SET(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
|
||||
SET(CPACK_RPM_DEBUGINFO_PACKAGE ON)
|
||||
ENDIF()
|
||||
|
||||
SET(CPACK_RPM_PACKAGE_RELEASE "1%{?dist}")
|
||||
SET(CPACK_RPM_PACKAGE_LICENSE "GPLv2")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2009, 2012, Oracle and/or its affiliates.
|
||||
# Copyright (c) 2011, 2017, MariaDB Corporation
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -11,7 +12,7 @@
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
MACRO (CHANGE_SSL_SETTINGS string)
|
||||
SET(WITH_SSL ${string} CACHE STRING "Options are: no bundled yes(prefer os library if present otherwise use bundled) system(use os library)" FORCE)
|
||||
@@ -87,7 +88,7 @@ MACRO (MYSQL_CHECK_SSL)
|
||||
CHANGE_SSL_SETTINGS("system")
|
||||
ELSE()
|
||||
IF(WITH_SSL STREQUAL "system")
|
||||
MESSAGE(SEND_ERROR "Cannot find appropriate system libraries for SSL. Use WITH_SSL=bundled to enable SSL support")
|
||||
MESSAGE(SEND_ERROR "Cannot find appropriate system libraries for SSL. Use WITH_SSL=bundled to enable SSL support")
|
||||
ENDIF()
|
||||
MYSQL_USE_BUNDLED_SSL()
|
||||
ENDIF()
|
||||
|
||||
2
debian/compat
vendored
2
debian/compat
vendored
@@ -1 +1 @@
|
||||
5
|
||||
9
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2001, 2013, Oracle and/or its affiliates.
|
||||
Copyright (c) 2009, 2017, MariaDB Corporation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -421,9 +422,8 @@ extern "C" int madvise(void *addr, size_t len, int behav);
|
||||
#define SIGNAL_HANDLER_RESET_ON_DELIVERY
|
||||
#endif
|
||||
|
||||
#ifndef STDERR_FILENO
|
||||
#define STDERR_FILENO fileno(stderr)
|
||||
#endif
|
||||
/* don't assume that STDERR_FILENO is 2, mysqld can freopen */
|
||||
#undef STDERR_FILENO
|
||||
|
||||
/*
|
||||
Deprecated workaround for false-positive uninitialized variables
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
|
||||
Copyright (c) 2010, 2016, Monty Program Ab.
|
||||
Copyright (c) 2010, 2017, MariaDB Corporation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -296,6 +296,8 @@ enum enum_server_command
|
||||
*/
|
||||
#define SERVER_PS_OUT_PARAMS 4096
|
||||
|
||||
#define SERVER_STATUS_ANSI_QUOTES 32768
|
||||
|
||||
/**
|
||||
Server status flags that must be cleared when starting
|
||||
execution of a new SQL statement.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2000, 2014, Oracle and/or its affiliates
|
||||
Copyright (c) 2009, 2014, Monty Program Ab
|
||||
Copyright (c) 2009, 2017, MariaDB Corporation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -4913,4 +4913,3 @@ ulong STDCALL mysql_net_field_length(uchar **packet)
|
||||
{
|
||||
return net_field_length(packet);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- cperl -*-
|
||||
|
||||
# Copyright (c) 2004, 2014, Oracle and/or its affiliates.
|
||||
# Copyright (c) 2009, 2014, Monty Program Ab
|
||||
# Copyright (c) 2009, 2017, MariaDB Corporation
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -6194,7 +6194,8 @@ sub valgrind_arguments {
|
||||
mtr_add_arg($args, "--num-callers=16");
|
||||
mtr_add_arg($args, "--suppressions=%s/valgrind.supp", $glob_mysql_test_dir)
|
||||
if -f "$glob_mysql_test_dir/valgrind.supp";
|
||||
my $temp= `ldd $ENV{MTR_BINDIR}/sql/mysqld | grep 'libjemalloc'`;
|
||||
my $exe_mysqld= find_mysqld($bindir) || "";
|
||||
my $temp= `ldd $exe_mysqld | grep 'libjemalloc'`;
|
||||
if ($temp)
|
||||
{
|
||||
mtr_add_arg($args, "--soname-synonyms=somalloc=libjemalloc*");
|
||||
|
||||
117
mysql-test/r/binary_to_hex.result
Normal file
117
mysql-test/r/binary_to_hex.result
Normal file
@@ -0,0 +1,117 @@
|
||||
USE test;
|
||||
DROP TABLE IF EXISTS t1, t2;
|
||||
CREATE TABLE t1 (c1 TINYBLOB,
|
||||
c2 BLOB,
|
||||
c3 MEDIUMBLOB,
|
||||
c4 LONGBLOB,
|
||||
c5 TEXT,
|
||||
c6 BIT(1),
|
||||
c7 CHAR,
|
||||
c8 VARCHAR(10),
|
||||
c9 GEOMETRY) CHARACTER SET = binary;
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`c1` tinyblob,
|
||||
`c2` blob,
|
||||
`c3` mediumblob,
|
||||
`c4` longblob,
|
||||
`c5` blob,
|
||||
`c6` bit(1) DEFAULT NULL,
|
||||
`c7` binary(1) DEFAULT NULL,
|
||||
`c8` varbinary(10) DEFAULT NULL,
|
||||
`c9` geometry DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=binary
|
||||
INSERT INTO t1 VALUES ('tinyblob-text readable', 'blob-text readable',
|
||||
'mediumblob-text readable', 'longblob-text readable',
|
||||
'text readable', b'1', 'c', 'variable',
|
||||
POINT(1, 1));
|
||||
CREATE TABLE t2(id int, `col1` binary(10),`col2` blob);
|
||||
SHOW CREATE TABLE t2;
|
||||
Table Create Table
|
||||
t2 CREATE TABLE `t2` (
|
||||
`id` int(11) DEFAULT NULL,
|
||||
`col1` binary(10) DEFAULT NULL,
|
||||
`col2` blob
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
INSERT INTO t2 VALUES (1, X'AB1234', X'123ABC'), (2, X'DE1234', X'123DEF');
|
||||
#Print the table contents when binary-as-hex option is off.
|
||||
SELECT * FROM t1;
|
||||
c1 c2 c3 c4 c5 c6 c7 c8 c9
|
||||
tinyblob-text readable blob-text readable mediumblob-text readable longblob-text readable text readable # c variable #
|
||||
SELECT * FROM t2;
|
||||
id col1 col2
|
||||
1 # #
|
||||
2 # #
|
||||
#Print the table contents after turning on the binary-as-hex option
|
||||
|
||||
#Print the table contents in tab format
|
||||
|
||||
c1 c2 c3 c4 c5 c6 c7 c8 c9
|
||||
0x74696E79626C6F622D74657874207265616461626C65 0x626C6F622D74657874207265616461626C65 0x6D656469756D626C6F622D74657874207265616461626C65 0x6C6F6E67626C6F622D74657874207265616461626C65 0x74657874207265616461626C65 0x01 0x63 0x7661726961626C65 0x000000000101000000000000000000F03F000000000000F03F
|
||||
id col1 col2
|
||||
1 0xAB123400000000000000 0x123ABC
|
||||
2 0xDE123400000000000000 0x123DEF
|
||||
|
||||
#Print the table contents in table format
|
||||
|
||||
+------------------------------------------------+----------------------------------------+----------------------------------------------------+------------------------------------------------+------------------------------+------------+------------+--------------------+------------------------------------------------------+
|
||||
| c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 | c9 |
|
||||
+------------------------------------------------+----------------------------------------+----------------------------------------------------+------------------------------------------------+------------------------------+------------+------------+--------------------+------------------------------------------------------+
|
||||
| 0x74696E79626C6F622D74657874207265616461626C65 | 0x626C6F622D74657874207265616461626C65 | 0x6D656469756D626C6F622D74657874207265616461626C65 | 0x6C6F6E67626C6F622D74657874207265616461626C65 | 0x74657874207265616461626C65 | 0x01 | 0x63 | 0x7661726961626C65 | 0x000000000101000000000000000000F03F000000000000F03F |
|
||||
+------------------------------------------------+----------------------------------------+----------------------------------------------------+------------------------------------------------+------------------------------+------------+------------+--------------------+------------------------------------------------------+
|
||||
+------+------------------------+------------+
|
||||
| id | col1 | col2 |
|
||||
+------+------------------------+------------+
|
||||
| 1 | 0xAB123400000000000000 | 0x123ABC |
|
||||
+------+------------------------+------------+
|
||||
|
||||
#Print the table contents vertically
|
||||
|
||||
*************************** 1. row ***************************
|
||||
c1: 0x74696E79626C6F622D74657874207265616461626C65
|
||||
c2: 0x626C6F622D74657874207265616461626C65
|
||||
c3: 0x6D656469756D626C6F622D74657874207265616461626C65
|
||||
c4: 0x6C6F6E67626C6F622D74657874207265616461626C65
|
||||
c5: 0x74657874207265616461626C65
|
||||
c6: 0x01
|
||||
c7: 0x63
|
||||
c8: 0x7661726961626C65
|
||||
c9: 0x000000000101000000000000000000F03F000000000000F03F
|
||||
|
||||
#Print the table contents in xml format
|
||||
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<resultset statement="SELECT * FROM t1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<row>
|
||||
<field name="c1">0x74696E79626C6F622D74657874207265616461626C65</field>
|
||||
<field name="c2">0x626C6F622D74657874207265616461626C65</field>
|
||||
<field name="c3">0x6D656469756D626C6F622D74657874207265616461626C65</field>
|
||||
<field name="c4">0x6C6F6E67626C6F622D74657874207265616461626C65</field>
|
||||
<field name="c5">0x74657874207265616461626C65</field>
|
||||
<field name="c6">0x01</field>
|
||||
<field name="c7">0x63</field>
|
||||
<field name="c8">0x7661726961626C65</field>
|
||||
<field name="c9">0x000000000101000000000000000000F03F000000000000F03F</field>
|
||||
</row>
|
||||
</resultset>
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<resultset statement="SELECT * FROM t2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<row>
|
||||
<field name="id">1</field>
|
||||
<field name="col1">0xAB123400000000000000</field>
|
||||
<field name="col2">0x123ABC</field>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<field name="id">2</field>
|
||||
<field name="col1">0xDE123400000000000000</field>
|
||||
<field name="col2">0x123DEF</field>
|
||||
</row>
|
||||
</resultset>
|
||||
|
||||
#Print the table contents in html format
|
||||
|
||||
<TABLE BORDER=1><TR><TH>c1</TH><TH>c2</TH><TH>c3</TH><TH>c4</TH><TH>c5</TH><TH>c6</TH><TH>c7</TH><TH>c8</TH><TH>c9</TH></TR><TR><TD>0x74696E79626C6F622D74657874207265616461626C65</TD><TD>0x626C6F622D74657874207265616461626C65</TD><TD>0x6D656469756D626C6F622D74657874207265616461626C65</TD><TD>0x6C6F6E67626C6F622D74657874207265616461626C65</TD><TD>0x74657874207265616461626C65</TD><TD>0x01</TD><TD>0x63</TD><TD>0x7661726961626C65</TD><TD>0x000000000101000000000000000000F03F000000000000F03F</TD></TR></TABLE><TABLE BORDER=1><TR><TH>id</TH><TH>col1</TH><TH>col2</TH></TR><TR><TD>1</TD><TD>0xAB123400000000000000</TD><TD>0x123ABC</TD></TR><TR><TD>2</TD><TD>0xDE123400000000000000</TD><TD>0x123DEF</TD></TR></TABLE>DROP TABLE t1, t2;
|
||||
@@ -94,3 +94,15 @@ count(distinct i)
|
||||
2
|
||||
drop table t1;
|
||||
drop view v1;
|
||||
create table t1 (user_id char(64) character set utf8);
|
||||
insert t1 values(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17);
|
||||
set @@tmp_table_size = 1024;
|
||||
select count(distinct user_id) from t1;
|
||||
count(distinct user_id)
|
||||
17
|
||||
alter table t1 modify user_id char(128) character set utf8;
|
||||
select count(distinct user_id) from t1;
|
||||
count(distinct user_id)
|
||||
17
|
||||
drop table t1;
|
||||
set @@tmp_table_size = default;
|
||||
|
||||
@@ -2579,5 +2579,64 @@ Handler_read_rnd_deleted 0
|
||||
Handler_read_rnd_next 27
|
||||
deallocate prepare stmt1;
|
||||
drop table t1,t2;
|
||||
#
|
||||
# Bug mdev-12670: mergeable derived / view with subqueries
|
||||
# subject to semi-join optimizations
|
||||
# (actually this is a 5.3 bug.)
|
||||
#
|
||||
create table t1 (a int) engine=myisam;
|
||||
insert into t1 values (5),(3),(2),(7),(2),(5),(1);
|
||||
create table t2 (b int, index idx(b)) engine=myisam;
|
||||
insert into t2 values (2),(3),(2),(1),(3),(4);
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
analyze table t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
explain select a from t1 where a in (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where
|
||||
1 PRIMARY t2 ref idx idx 5 test.t1.a 140 Using index; FirstMatch(t1)
|
||||
explain select * from (select a from t1 where a in (select b from t2)) t;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where
|
||||
1 SIMPLE t2 ref idx idx 5 test.t1.a 140 Using index; FirstMatch(t1)
|
||||
create view v1 as select a from t1 where a in (select b from t2);
|
||||
explain select * from v1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where
|
||||
1 SIMPLE t2 ref idx idx 5 test.t1.a 140 Using index; FirstMatch(t1)
|
||||
drop view v1;
|
||||
drop table t1,t2;
|
||||
#
|
||||
# Bug mdev-12812: mergeable derived / view with subqueries
|
||||
# NOT subject to semi-join optimizations
|
||||
#
|
||||
CREATE TABLE t1 (c1 varchar(3)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('foo'),('foo');
|
||||
CREATE TABLE t2 (c2 varchar(3)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES ('bar'),('qux'),('foo');
|
||||
SELECT STRAIGHT_JOIN *
|
||||
FROM ( SELECT * FROM t1 WHERE c1 IN ( SELECT c2 FROM t2 ) ) AS sq;
|
||||
c1
|
||||
foo
|
||||
foo
|
||||
EXPLAIN EXTENDED SELECT STRAIGHT_JOIN *
|
||||
FROM ( SELECT * FROM t1 WHERE c1 IN ( SELECT c2 FROM t2 ) ) AS sq;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`c1`,<exists>(select `test`.`t2`.`c2` from `test`.`t2` where (<cache>(`test`.`t1`.`c1`) = `test`.`t2`.`c2`)))
|
||||
DROP TABLE t1, t2;
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
set join_cache_level=@exit_join_cache_level;
|
||||
|
||||
@@ -2531,3 +2531,30 @@ select a from t1 group by a having a > 1;
|
||||
a
|
||||
drop table t1;
|
||||
set sql_mode= @save_sql_mode;
|
||||
create table t1 (f1 int);
|
||||
insert into t1 values (5),(9);
|
||||
create table t2 (f2 int);
|
||||
insert into t2 values (0),(6);
|
||||
create table t3 (f3 int);
|
||||
insert into t3 values (6),(3);
|
||||
create table t4 (f4 int);
|
||||
insert into t4 values (1),(0);
|
||||
select
|
||||
(select min(f1) from t1 where f1 in (select min(f4) from t2)) as field7,
|
||||
(select count(*) from t3 where f3 in (select max(f4) from t2 group by field7))
|
||||
from t4;
|
||||
ERROR 42S22: Reference 'field7' not supported (reference to group function)
|
||||
drop table t1, t2, t3, t4;
|
||||
create table t1 (i1 int);
|
||||
insert into t1 values (1);
|
||||
create table t2 (i int);
|
||||
insert into t2 values (2);
|
||||
select 1 from t1 left join t2 b on b.i = (select max(b.i) from t2);
|
||||
1
|
||||
1
|
||||
drop table t1, t2;
|
||||
create table t1 (c1 int, c2 int);
|
||||
create table t2 (c1 int, c2 int);
|
||||
select t1.c1 as c1, t2.c2 as c1 from t1, t2 where t1.c1 < 20 and t2.c2 > 5 group by t1.c1, t2.c2 having t1.c1 < 3;
|
||||
c1 c1
|
||||
drop table t1, t2;
|
||||
|
||||
@@ -2245,4 +2245,99 @@ SELECT * FROM t1 INNER JOIN t2 ON c = b LEFT JOIN t3 ON d = a
|
||||
WHERE b IN (1,2,3) OR b = d;
|
||||
a b c d
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# MDEV-11958: LEFT JOIN with stored routine produces incorrect result
|
||||
#
|
||||
CREATE TABLE t (x INT);
|
||||
INSERT INTO t VALUES(1),(NULL);
|
||||
CREATE FUNCTION f (val INT, ret INT) RETURNS INT DETERMINISTIC RETURN IFNULL(val, ret);
|
||||
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
|
||||
FROM t t1 LEFT JOIN t t2
|
||||
ON t1.x = t2.x
|
||||
WHERE IFNULL(t2.x,0)=0;
|
||||
x x IFNULL(t2.x,0) f(t2.x,0)
|
||||
NULL NULL 0 0
|
||||
explain extended
|
||||
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
|
||||
FROM t t1 LEFT JOIN t t2
|
||||
ON t1.x = t2.x
|
||||
WHERE IFNULL(t2.x,0)=0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t2`.`x` AS `x`,ifnull(`test`.`t2`.`x`,0) AS `IFNULL(t2.x,0)`,`f`(`test`.`t2`.`x`,0) AS `f(t2.x,0)` from `test`.`t` `t1` left join `test`.`t` `t2` on((`test`.`t2`.`x` = `test`.`t1`.`x`)) where (ifnull(`test`.`t2`.`x`,0) = 0)
|
||||
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
|
||||
FROM t t1 LEFT JOIN t t2
|
||||
ON t1.x = t2.x
|
||||
WHERE f(t2.x,0)=0;
|
||||
x x IFNULL(t2.x,0) f(t2.x,0)
|
||||
NULL NULL 0 0
|
||||
explain extended
|
||||
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
|
||||
FROM t t1 LEFT JOIN t t2
|
||||
ON t1.x = t2.x
|
||||
WHERE f(t2.x,0)=0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t2`.`x` AS `x`,ifnull(`test`.`t2`.`x`,0) AS `IFNULL(t2.x,0)`,`f`(`test`.`t2`.`x`,0) AS `f(t2.x,0)` from `test`.`t` `t1` left join `test`.`t` `t2` on((`test`.`t2`.`x` = `test`.`t1`.`x`)) where (`f`(`test`.`t2`.`x`,0) = 0)
|
||||
drop function f;
|
||||
drop table t;
|
||||
CREATE TABLE t1 (
|
||||
col1 DECIMAL(33,5) NULL DEFAULT NULL,
|
||||
col2 DECIMAL(33,5) NULL DEFAULT NULL
|
||||
);
|
||||
CREATE TABLE t2 (
|
||||
col1 DECIMAL(33,5) NULL DEFAULT NULL,
|
||||
col2 DECIMAL(33,5) NULL DEFAULT NULL,
|
||||
col3 DECIMAL(33,5) NULL DEFAULT NULL
|
||||
);
|
||||
INSERT INTO t1 VALUES (2, 1.1), (2, 2.1);
|
||||
INSERT INTO t2 VALUES (3, 3.1, 4), (1, 1, NULL);
|
||||
CREATE FUNCTION f1 ( p_num DECIMAL(45,15), p_return DECIMAL(45,15))
|
||||
RETURNS decimal(33,5)
|
||||
LANGUAGE SQL
|
||||
DETERMINISTIC
|
||||
CONTAINS SQL
|
||||
SQL SECURITY INVOKER
|
||||
BEGIN
|
||||
IF p_num IS NULL THEN
|
||||
RETURN p_return;
|
||||
ELSE
|
||||
RETURN p_num;
|
||||
END IF;
|
||||
END |
|
||||
SELECT t1.col1, t2.col1, t2.col3
|
||||
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
|
||||
WHERE IFNULL(t2.col3,0) = 0;
|
||||
col1 col1 col3
|
||||
2.00000 NULL NULL
|
||||
2.00000 NULL NULL
|
||||
EXPLAIN EXTENDED SELECT t1.col1, t2.col1, t2.col3
|
||||
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
|
||||
WHERE IFNULL(t2.col3,0) = 0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1`,`test`.`t2`.`col3` AS `col3` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col2` = `test`.`t1`.`col1`)) where (ifnull(`test`.`t2`.`col3`,0) = 0)
|
||||
SELECT t1.col1, t2.col1, t2.col3
|
||||
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
|
||||
WHERE f1(t2.col3,0) = 0;
|
||||
col1 col1 col3
|
||||
2.00000 NULL NULL
|
||||
2.00000 NULL NULL
|
||||
EXPLAIN EXTENDED SELECT t1.col1, t2.col1, t2.col3
|
||||
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
|
||||
WHERE f1(t2.col3,0) = 0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1`,`test`.`t2`.`col3` AS `col3` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col2` = `test`.`t1`.`col1`)) where (`f1`(`test`.`t2`.`col3`,0) = 0)
|
||||
DROP FUNCTION f1;
|
||||
DROP TABLE t1,t2;
|
||||
# end of 5.5 tests
|
||||
SET optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
@@ -2256,6 +2256,101 @@ SELECT * FROM t1 INNER JOIN t2 ON c = b LEFT JOIN t3 ON d = a
|
||||
WHERE b IN (1,2,3) OR b = d;
|
||||
a b c d
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# MDEV-11958: LEFT JOIN with stored routine produces incorrect result
|
||||
#
|
||||
CREATE TABLE t (x INT);
|
||||
INSERT INTO t VALUES(1),(NULL);
|
||||
CREATE FUNCTION f (val INT, ret INT) RETURNS INT DETERMINISTIC RETURN IFNULL(val, ret);
|
||||
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
|
||||
FROM t t1 LEFT JOIN t t2
|
||||
ON t1.x = t2.x
|
||||
WHERE IFNULL(t2.x,0)=0;
|
||||
x x IFNULL(t2.x,0) f(t2.x,0)
|
||||
NULL NULL 0 0
|
||||
explain extended
|
||||
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
|
||||
FROM t t1 LEFT JOIN t t2
|
||||
ON t1.x = t2.x
|
||||
WHERE IFNULL(t2.x,0)=0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t2`.`x` AS `x`,ifnull(`test`.`t2`.`x`,0) AS `IFNULL(t2.x,0)`,`f`(`test`.`t2`.`x`,0) AS `f(t2.x,0)` from `test`.`t` `t1` left join `test`.`t` `t2` on((`test`.`t2`.`x` = `test`.`t1`.`x`)) where (ifnull(`test`.`t2`.`x`,0) = 0)
|
||||
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
|
||||
FROM t t1 LEFT JOIN t t2
|
||||
ON t1.x = t2.x
|
||||
WHERE f(t2.x,0)=0;
|
||||
x x IFNULL(t2.x,0) f(t2.x,0)
|
||||
NULL NULL 0 0
|
||||
explain extended
|
||||
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
|
||||
FROM t t1 LEFT JOIN t t2
|
||||
ON t1.x = t2.x
|
||||
WHERE f(t2.x,0)=0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t2`.`x` AS `x`,ifnull(`test`.`t2`.`x`,0) AS `IFNULL(t2.x,0)`,`f`(`test`.`t2`.`x`,0) AS `f(t2.x,0)` from `test`.`t` `t1` left join `test`.`t` `t2` on((`test`.`t2`.`x` = `test`.`t1`.`x`)) where (`f`(`test`.`t2`.`x`,0) = 0)
|
||||
drop function f;
|
||||
drop table t;
|
||||
CREATE TABLE t1 (
|
||||
col1 DECIMAL(33,5) NULL DEFAULT NULL,
|
||||
col2 DECIMAL(33,5) NULL DEFAULT NULL
|
||||
);
|
||||
CREATE TABLE t2 (
|
||||
col1 DECIMAL(33,5) NULL DEFAULT NULL,
|
||||
col2 DECIMAL(33,5) NULL DEFAULT NULL,
|
||||
col3 DECIMAL(33,5) NULL DEFAULT NULL
|
||||
);
|
||||
INSERT INTO t1 VALUES (2, 1.1), (2, 2.1);
|
||||
INSERT INTO t2 VALUES (3, 3.1, 4), (1, 1, NULL);
|
||||
CREATE FUNCTION f1 ( p_num DECIMAL(45,15), p_return DECIMAL(45,15))
|
||||
RETURNS decimal(33,5)
|
||||
LANGUAGE SQL
|
||||
DETERMINISTIC
|
||||
CONTAINS SQL
|
||||
SQL SECURITY INVOKER
|
||||
BEGIN
|
||||
IF p_num IS NULL THEN
|
||||
RETURN p_return;
|
||||
ELSE
|
||||
RETURN p_num;
|
||||
END IF;
|
||||
END |
|
||||
SELECT t1.col1, t2.col1, t2.col3
|
||||
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
|
||||
WHERE IFNULL(t2.col3,0) = 0;
|
||||
col1 col1 col3
|
||||
2.00000 NULL NULL
|
||||
2.00000 NULL NULL
|
||||
EXPLAIN EXTENDED SELECT t1.col1, t2.col1, t2.col3
|
||||
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
|
||||
WHERE IFNULL(t2.col3,0) = 0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1`,`test`.`t2`.`col3` AS `col3` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col2` = `test`.`t1`.`col1`)) where (ifnull(`test`.`t2`.`col3`,0) = 0)
|
||||
SELECT t1.col1, t2.col1, t2.col3
|
||||
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
|
||||
WHERE f1(t2.col3,0) = 0;
|
||||
col1 col1 col3
|
||||
2.00000 NULL NULL
|
||||
2.00000 NULL NULL
|
||||
EXPLAIN EXTENDED SELECT t1.col1, t2.col1, t2.col3
|
||||
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
|
||||
WHERE f1(t2.col3,0) = 0;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1`,`test`.`t2`.`col3` AS `col3` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col2` = `test`.`t1`.`col1`)) where (`f1`(`test`.`t2`.`col3`,0) = 0)
|
||||
DROP FUNCTION f1;
|
||||
DROP TABLE t1,t2;
|
||||
# end of 5.5 tests
|
||||
SET optimizer_switch=@save_optimizer_switch;
|
||||
set join_cache_level=default;
|
||||
show variables like 'join_cache_level';
|
||||
|
||||
@@ -426,7 +426,7 @@ c1
|
||||
bb
|
||||
cc
|
||||
Warnings:
|
||||
Warning 1931 Query execution was interrupted. The query examined at least 18 rows, which exceeds LIMIT ROWS EXAMINED (16). The query result may be incomplete.
|
||||
Warning 1931 Query execution was interrupted. The query examined at least 17 rows, which exceeds LIMIT ROWS EXAMINED (16). The query result may be incomplete.
|
||||
select * from v1 LIMIT ROWS EXAMINED 11;
|
||||
c1
|
||||
bb
|
||||
@@ -439,7 +439,8 @@ from (select * from t1
|
||||
where c1 IN (select * from t2 where c2 > ' ' LIMIT ROWS EXAMINED 0)) as tmp
|
||||
LIMIT ROWS EXAMINED 11;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
|
||||
1 SIMPLE <subquery3> eq_ref distinct_key distinct_key 2 func 1
|
||||
3 MATERIALIZED t2 ALL NULL NULL NULL NULL 4 Using where
|
||||
select *
|
||||
from (select * from t1
|
||||
|
||||
@@ -5,10 +5,10 @@ load xml infile '../../std_data/loadxml.dat' into table t1
|
||||
rows identified by '<row>';
|
||||
select * from t1 order by a;
|
||||
a b
|
||||
1 b1
|
||||
2 b2
|
||||
3 b3
|
||||
11 b11
|
||||
1 b1
|
||||
2 b2
|
||||
3 b3
|
||||
11 b11
|
||||
111 b111
|
||||
112 b112 & < > " ' &unknown; -- check entities
|
||||
212 b212
|
||||
@@ -81,17 +81,17 @@ LOAD XML INFILE '../../std_data/loadxml.dat' INTO TABLE t1
|
||||
ROWS IDENTIFIED BY '<row>' (a,@b) SET b=concat('!',@b);
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
a b
|
||||
1 !b1
|
||||
11 !b11
|
||||
1 ! b1
|
||||
11 ! b11
|
||||
111 !b111
|
||||
112 !b112 & < > " ' &unknown; -- check entities
|
||||
2 !b2
|
||||
2 ! b2
|
||||
212 !b212
|
||||
213 !b213
|
||||
214 !b214
|
||||
215 !b215
|
||||
216 !&bb b;
|
||||
3 !b3
|
||||
3 ! b3
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# Bug#16171518 LOAD XML DOES NOT HANDLE EMPTY ELEMENTS
|
||||
|
||||
@@ -529,3 +529,61 @@ a
|
||||
+-------------------+
|
||||
|
||||
End of tests
|
||||
create table `a1\``b1` (a int);
|
||||
show tables;
|
||||
Tables_in_test
|
||||
a1\`b1
|
||||
insert `a1\``b1` values (1),(2);
|
||||
show create table `a1\``b1`;
|
||||
Table Create Table
|
||||
a1\`b1 CREATE TABLE `a1\``b1` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `a1\``b1` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
INSERT INTO `a1\``b1` VALUES (1),(2);
|
||||
insert `a1\``b1` values (4),(5);
|
||||
show create table `a1\``b1`;
|
||||
Table Create Table
|
||||
a1\`b1 CREATE TABLE `a1\``b1` (
|
||||
`a` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
select * from `a1\``b1`;
|
||||
a
|
||||
1
|
||||
2
|
||||
drop table `a1\``b1`;
|
||||
set sql_mode=ansi_quotes;
|
||||
create table "a1\""b1" (a int);
|
||||
show tables;
|
||||
Tables_in_test
|
||||
a1\"b1
|
||||
insert "a1\""b1" values (1),(2);
|
||||
show create table "a1\""b1";
|
||||
Table Create Table
|
||||
a1\"b1 CREATE TABLE "a1\""b1" (
|
||||
"a" int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE "a1\""b1" (
|
||||
"a" int(11) DEFAULT NULL
|
||||
);
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
INSERT INTO "a1\""b1" VALUES (1),(2);
|
||||
insert "a1\""b1" values (4),(5);
|
||||
show create table "a1\""b1";
|
||||
Table Create Table
|
||||
a1\"b1 CREATE TABLE "a1\""b1" (
|
||||
"a" int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
select * from "a1\""b1";
|
||||
a
|
||||
1
|
||||
2
|
||||
drop table "a1\""b1";
|
||||
set sql_mode=default;
|
||||
|
||||
@@ -957,4 +957,9 @@ con1
|
||||
con2
|
||||
con2
|
||||
-closed_connection-
|
||||
set sql_mode=no_backslash_escapes;
|
||||
select "foo\""bar";
|
||||
foo\"bar
|
||||
foo\"bar
|
||||
set sql_mode=default;
|
||||
End of tests
|
||||
|
||||
@@ -30,6 +30,8 @@ create temporary table t3 (a int);
|
||||
create temporary table t4 (a int) select * from t3;
|
||||
insert into t3 values(1);
|
||||
insert into t4 select * from t3;
|
||||
create table t3 (a int);
|
||||
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
||||
update t1,t3 set t1.a=t3.a+1 where t1.a=t3.a;
|
||||
ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement
|
||||
update t1,t3 set t3.a=t1.a+1 where t1.a=t3.a;
|
||||
|
||||
@@ -7116,3 +7116,33 @@ SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
|
||||
f1 f2
|
||||
foo bar
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-10146: Wrong result (or questionable result and behavior)
|
||||
# with aggregate function in uncorrelated SELECT subquery
|
||||
#
|
||||
CREATE TABLE t1 (f1 INT);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2 (f2 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
|
||||
( SELECT MAX(f1) FROM t2 )
|
||||
2
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
|
||||
( SELECT MAX(f1) FROM t2 )
|
||||
2
|
||||
INSERT INTO t2 VALUES (4);
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
drop view v1;
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (f1 INT, KEY(f1)) ENGINE=MyISAM;
|
||||
INSERT t1 VALUES (4),(8);
|
||||
CREATE TABLE t2 (f2 INT, KEY(f2)) ENGINE=MyISAM;
|
||||
INSERT t2 VALUES (6),(9);
|
||||
SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
|
||||
(SELECT MAX(sq.f2) FROM t1)
|
||||
NULL
|
||||
drop table t1, t2;
|
||||
|
||||
@@ -2272,6 +2272,94 @@ pk f1 sq
|
||||
5 3 5
|
||||
set optimizer_switch= @save_optimizer_switch;
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# mdev-12838: scan of materialized of semi-join subquery in join
|
||||
#
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
CREATE TABLE t1 (
|
||||
dispatch_group varchar(32),
|
||||
assignment_group varchar(32),
|
||||
sys_id char(32),
|
||||
PRIMARY KEY (sys_id),
|
||||
KEY idx1 (dispatch_group),
|
||||
KEY idx2 (assignment_group)
|
||||
) ENGINE=MyISAM;
|
||||
CREATE TABLE t2 (
|
||||
ugroup varchar(32),
|
||||
user varchar(32),
|
||||
sys_id char(32),
|
||||
PRIMARY KEY (sys_id),
|
||||
KEY idx3 (ugroup),
|
||||
KEY idx4 (user)
|
||||
) ENGINE=MyISAM;
|
||||
CREATE TABLE t3 (
|
||||
type mediumtext,
|
||||
sys_id char(32),
|
||||
PRIMARY KEY (sys_id)
|
||||
) ENGINE=MyISAM;
|
||||
set optimizer_switch='materialization=off';
|
||||
explain SELECT t1.assignment_group
|
||||
FROM t1, t3
|
||||
WHERE t1.assignment_group = t3.sys_id AND
|
||||
t1.dispatch_group IN
|
||||
(SELECT t2.ugroup
|
||||
FROM t2, t3 t3_i
|
||||
WHERE t2.ugroup = t3_i.sys_id AND
|
||||
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
|
||||
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where; Start temporary
|
||||
1 PRIMARY t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where
|
||||
1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t3_i.sys_id 2 Using index condition; Using where; End temporary
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 32 test.t1.assignment_group 1 Using where; Using index
|
||||
SELECT t1.assignment_group
|
||||
FROM t1, t3
|
||||
WHERE t1.assignment_group = t3.sys_id AND
|
||||
t1.dispatch_group IN
|
||||
(SELECT t2.ugroup
|
||||
FROM t2, t3 t3_i
|
||||
WHERE t2.ugroup = t3_i.sys_id AND
|
||||
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
|
||||
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
|
||||
assignment_group
|
||||
df50316637232000158bbfc8bcbe5d23
|
||||
e08fad2637232000158bbfc8bcbe5d39
|
||||
ec70316637232000158bbfc8bcbe5d60
|
||||
7b10fd2637232000158bbfc8bcbe5d30
|
||||
ebb4620037332000158bbfc8bcbe5d89
|
||||
set optimizer_switch='materialization=on';
|
||||
explain SELECT t1.assignment_group
|
||||
FROM t1, t3
|
||||
WHERE t1.assignment_group = t3.sys_id AND
|
||||
t1.dispatch_group IN
|
||||
(SELECT t2.ugroup
|
||||
FROM t2, t3 t3_i
|
||||
WHERE t2.ugroup = t3_i.sys_id AND
|
||||
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
|
||||
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t2.ugroup 2 Using where
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 32 test.t1.assignment_group 1 Using where; Using index
|
||||
2 MATERIALIZED t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where
|
||||
2 MATERIALIZED t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where
|
||||
SELECT t1.assignment_group
|
||||
FROM t1, t3
|
||||
WHERE t1.assignment_group = t3.sys_id AND
|
||||
t1.dispatch_group IN
|
||||
(SELECT t2.ugroup
|
||||
FROM t2, t3 t3_i
|
||||
WHERE t2.ugroup = t3_i.sys_id AND
|
||||
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
|
||||
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
|
||||
assignment_group
|
||||
df50316637232000158bbfc8bcbe5d23
|
||||
e08fad2637232000158bbfc8bcbe5d39
|
||||
ec70316637232000158bbfc8bcbe5d60
|
||||
7b10fd2637232000158bbfc8bcbe5d30
|
||||
ebb4620037332000158bbfc8bcbe5d89
|
||||
DROP TABLE t1,t2,t3;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
# End of 5.5 tests
|
||||
set @subselect_mat_test_optimizer_switch_value=null;
|
||||
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
|
||||
|
||||
@@ -379,6 +379,7 @@ drop table t3, t4, t5;
|
||||
#
|
||||
# LP BUG#858038 The result of a query with NOT IN subquery depends on the state of the optimizer switch
|
||||
#
|
||||
set @optimizer_switch_save= @@optimizer_switch;
|
||||
create table t1 (c1 char(2) not null, c2 char(2));
|
||||
create table t2 (c3 char(2), c4 char(2));
|
||||
insert into t1 values ('a1', 'b1');
|
||||
@@ -400,3 +401,104 @@ id select_type table type possible_keys key key_len ref rows Extra
|
||||
select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2);
|
||||
c1 c2
|
||||
drop table t1, t2;
|
||||
set optimizer_switch= @optimizer_switch_save;
|
||||
#
|
||||
# MDEV-12673: cost-based choice between materialization and in-to-exists
|
||||
#
|
||||
CREATE TABLE t1 (
|
||||
pk1 int, a1 varchar(3), b1 varchar(3), PRIMARY KEY (pk1), KEY(a1), KEY(b1)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1,'foo','bar'),(2,'bar','foo');
|
||||
CREATE TABLE t2 (pk2 INT PRIMARY KEY, a2 VARCHAR(3), KEY(a2)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1,'abc'),(2,'xyz'),(3,'foo');
|
||||
SELECT 'qux' IN ( SELECT a1 FROM t1 INNER JOIN t2 WHERE a2 = b1 AND pk2 = 3 );
|
||||
'qux' IN ( SELECT a1 FROM t1 INNER JOIN t2 WHERE a2 = b1 AND pk2 = 3 )
|
||||
0
|
||||
SELECT 'bar' IN ( SELECT a1 FROM t1 INNER JOIN t2 WHERE a2 = b1 AND pk2 = 3 );
|
||||
'bar' IN ( SELECT a1 FROM t1 INNER JOIN t2 WHERE a2 = b1 AND pk2 = 3 )
|
||||
1
|
||||
EXPLAIN
|
||||
SELECT 'bar' IN ( SELECT a1 FROM t1 INNER JOIN t2 WHERE a2 = b1 AND pk2 = 3 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
2 SUBQUERY t2 const PRIMARY,a2 PRIMARY 4 const 1
|
||||
2 SUBQUERY t1 ref a1,b1 b1 6 const 1 Using where
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (i1 INT) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1);
|
||||
CREATE TABLE t2 (i2 int, c2 varchar(3), KEY(i2,c2)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1,'abc'),(2,'foo');
|
||||
CREATE TABLE t3 (pk3 int PRIMARY KEY, c3 varchar(3)) ENGINE=MyISAM;
|
||||
INSERT INTO t3 VALUES (1,'foo'),(2,'bar');
|
||||
SELECT * FROM t1 WHERE i1 NOT IN (
|
||||
SELECT i2 FROM t2 RIGHT JOIN t3 ON (c3 = c2) WHERE pk3 = i1
|
||||
);
|
||||
i1
|
||||
1
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE i1 NOT IN (
|
||||
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
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# MDEV-7599: in-to-exists chosen after min/max optimization
|
||||
#
|
||||
set @optimizer_switch_save= @@optimizer_switch;
|
||||
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2 (b INT, c INT) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1,6),(2,4), (8,9);
|
||||
SELECT * FROM t2 WHERE b != ALL (SELECT MIN(a) FROM t1, t2 WHERE t2.c = t2.b);
|
||||
b c
|
||||
EXPLAIN EXTENDED SELECT * FROM t2 WHERE b != ALL (SELECT MIN(a) FROM t1, t2 WHERE t2.c = t2.b);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
2 MATERIALIZED t1 index NULL a 5 NULL 2 100.00 Using index
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where (not(<expr_cache><`test`.`t2`.`b`>(<in_optimizer>(`test`.`t2`.`b`,`test`.`t2`.`b` in ( <materialize> (select min(`test`.`t1`.`a`) from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = `test`.`t2`.`b`) ), <primary_index_lookup>(`test`.`t2`.`b` in <temporary table> on distinct_key where ((`test`.`t2`.`b` = `<subquery2>`.`MIN(a)`))))))))
|
||||
set optimizer_switch= 'materialization=off';
|
||||
SELECT * FROM t2 WHERE b != ALL (SELECT MIN(a) FROM t1, t2 WHERE t2.c = t2.b);
|
||||
b c
|
||||
EXPLAIN EXTENDED SELECT * FROM t2 WHERE b != ALL (SELECT MIN(a) FROM t1, t2 WHERE t2.c = t2.b);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using where
|
||||
2 DEPENDENT SUBQUERY t1 index NULL a 5 NULL 2 100.00 Using index
|
||||
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where (not(<expr_cache><`test`.`t2`.`b`>(<in_optimizer>(`test`.`t2`.`b`,<exists>(select min(`test`.`t1`.`a`) from `test`.`t1` join `test`.`t2` where (`test`.`t2`.`c` = `test`.`t2`.`b`) having trigcond((<cache>(`test`.`t2`.`b`) = <ref_null_helper>(min(`test`.`t1`.`a`)))))))))
|
||||
set optimizer_switch= @optimizer_switch_save;
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (f1 varchar(10)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('foo'),('bar');
|
||||
CREATE TABLE t2 (f2 varchar(10), key(f2)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES ('baz'),('qux');
|
||||
CREATE TABLE t3 (f3 varchar(10)) ENGINE=MyISAM;
|
||||
INSERT INTO t3 VALUES ('abc'),('def');
|
||||
SELECT * FROM t1
|
||||
WHERE f1 = ALL( SELECT MAX(t2a.f2)
|
||||
FROM t2 AS t2a INNER JOIN t2 t2b INNER JOIN t3
|
||||
ON (f3 = t2b.f2) );
|
||||
f1
|
||||
DROP TABLE t1,t2,t3;
|
||||
#
|
||||
# MDEV-12963: min/max optimization optimizing away all tables employed
|
||||
# for uncorrelated IN subquery used in a disjunct of WHERE
|
||||
#
|
||||
create table t1 (a int, index idx(a)) engine=myisam;
|
||||
insert into t1 values (4),(7),(1),(3),(9);
|
||||
select * from t1 where a in (select max(a) from t1 where a < 4) or a > 5;
|
||||
a
|
||||
3
|
||||
7
|
||||
9
|
||||
explain
|
||||
select * from t1 where a in (select max(a) from t1 where a < 4) or a > 5;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index idx idx 5 NULL 5 Using where; Using index
|
||||
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
|
||||
drop table t1;
|
||||
|
||||
@@ -7113,6 +7113,36 @@ SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
|
||||
f1 f2
|
||||
foo bar
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-10146: Wrong result (or questionable result and behavior)
|
||||
# with aggregate function in uncorrelated SELECT subquery
|
||||
#
|
||||
CREATE TABLE t1 (f1 INT);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2 (f2 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
|
||||
( SELECT MAX(f1) FROM t2 )
|
||||
2
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
|
||||
( SELECT MAX(f1) FROM t2 )
|
||||
2
|
||||
INSERT INTO t2 VALUES (4);
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
drop view v1;
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (f1 INT, KEY(f1)) ENGINE=MyISAM;
|
||||
INSERT t1 VALUES (4),(8);
|
||||
CREATE TABLE t2 (f2 INT, KEY(f2)) ENGINE=MyISAM;
|
||||
INSERT t2 VALUES (6),(9);
|
||||
SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
|
||||
(SELECT MAX(sq.f2) FROM t1)
|
||||
NULL
|
||||
drop table t1, t2;
|
||||
set optimizer_switch=default;
|
||||
select @@optimizer_switch like '%materialization=on%';
|
||||
@@optimizer_switch like '%materialization=on%'
|
||||
|
||||
@@ -7111,4 +7111,34 @@ SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
|
||||
f1 f2
|
||||
foo bar
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-10146: Wrong result (or questionable result and behavior)
|
||||
# with aggregate function in uncorrelated SELECT subquery
|
||||
#
|
||||
CREATE TABLE t1 (f1 INT);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2 (f2 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
|
||||
( SELECT MAX(f1) FROM t2 )
|
||||
2
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
|
||||
( SELECT MAX(f1) FROM t2 )
|
||||
2
|
||||
INSERT INTO t2 VALUES (4);
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
drop view v1;
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (f1 INT, KEY(f1)) ENGINE=MyISAM;
|
||||
INSERT t1 VALUES (4),(8);
|
||||
CREATE TABLE t2 (f2 INT, KEY(f2)) ENGINE=MyISAM;
|
||||
INSERT t2 VALUES (6),(9);
|
||||
SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
|
||||
(SELECT MAX(sq.f2) FROM t1)
|
||||
NULL
|
||||
drop table t1, t2;
|
||||
set @optimizer_switch_for_subselect_test=null;
|
||||
|
||||
@@ -7122,6 +7122,36 @@ SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
|
||||
f1 f2
|
||||
foo bar
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-10146: Wrong result (or questionable result and behavior)
|
||||
# with aggregate function in uncorrelated SELECT subquery
|
||||
#
|
||||
CREATE TABLE t1 (f1 INT);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2 (f2 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
|
||||
( SELECT MAX(f1) FROM t2 )
|
||||
2
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
|
||||
( SELECT MAX(f1) FROM t2 )
|
||||
2
|
||||
INSERT INTO t2 VALUES (4);
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
drop view v1;
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (f1 INT, KEY(f1)) ENGINE=MyISAM;
|
||||
INSERT t1 VALUES (4),(8);
|
||||
CREATE TABLE t2 (f2 INT, KEY(f2)) ENGINE=MyISAM;
|
||||
INSERT t2 VALUES (6),(9);
|
||||
SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
|
||||
(SELECT MAX(sq.f2) FROM t1)
|
||||
NULL
|
||||
drop table t1, t2;
|
||||
set optimizer_switch=default;
|
||||
select @@optimizer_switch like '%subquery_cache=on%';
|
||||
@@optimizer_switch like '%subquery_cache=on%'
|
||||
|
||||
@@ -7111,5 +7111,35 @@ SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
|
||||
f1 f2
|
||||
foo bar
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-10146: Wrong result (or questionable result and behavior)
|
||||
# with aggregate function in uncorrelated SELECT subquery
|
||||
#
|
||||
CREATE TABLE t1 (f1 INT);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2 (f2 int);
|
||||
INSERT INTO t2 VALUES (3);
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
|
||||
( SELECT MAX(f1) FROM t2 )
|
||||
2
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
|
||||
( SELECT MAX(f1) FROM t2 )
|
||||
2
|
||||
INSERT INTO t2 VALUES (4);
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
drop view v1;
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t1 (f1 INT, KEY(f1)) ENGINE=MyISAM;
|
||||
INSERT t1 VALUES (4),(8);
|
||||
CREATE TABLE t2 (f2 INT, KEY(f2)) ENGINE=MyISAM;
|
||||
INSERT t2 VALUES (6),(9);
|
||||
SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
|
||||
(SELECT MAX(sq.f2) FROM t1)
|
||||
NULL
|
||||
drop table t1, t2;
|
||||
set @optimizer_switch_for_subselect_test=null;
|
||||
set @join_cache_level_for_subselect_test=NULL;
|
||||
|
||||
@@ -115,3 +115,9 @@ k d1 d2
|
||||
set optimizer_switch= @tmp_subselect_nulls;
|
||||
drop table x1;
|
||||
drop table x2;
|
||||
select (select 1, 2) in (select 3, 4);
|
||||
(select 1, 2) in (select 3, 4)
|
||||
0
|
||||
select (select NULL, NULL) in (select 3, 4);
|
||||
(select NULL, NULL) in (select 3, 4)
|
||||
NULL
|
||||
|
||||
@@ -1650,9 +1650,9 @@ CREATE VIEW v1 AS SELECT 1;
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived3> system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED <derived3> system NULL NULL NULL NULL 1
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
|
||||
a a
|
||||
@@ -3060,4 +3060,97 @@ project_number
|
||||
aaa
|
||||
drop table t1, t2, t3;
|
||||
set optimizer_switch= @tmp_mdev6859;
|
||||
#
|
||||
# MDEV-12675: subquery subject to semi-join optimizations
|
||||
# in ON expression of INNER JOIN
|
||||
#
|
||||
set @tmp_mdev12675=@@optimizer_switch;
|
||||
set optimizer_switch=default;
|
||||
create table t1 (a int) engine=myisam;
|
||||
insert into t1 values (5),(3),(2),(7),(2),(5),(1);
|
||||
create table t2 (b int, index idx(b)) engine=myisam;
|
||||
insert into t2 values (2),(3),(2),(1),(3),(4);
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
analyze table t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
explain
|
||||
select a from t1, t2 where b between 1 and 2 and a in (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where
|
||||
1 PRIMARY t2 ref idx idx 5 test.t1.a 256 Using index; FirstMatch(t1)
|
||||
1 PRIMARY t2 range idx idx 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
explain
|
||||
select a from t1 join t2 on b between 1 and 2 and a in (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where
|
||||
1 PRIMARY t2 ref idx idx 5 test.t1.a 256 Using index; FirstMatch(t1)
|
||||
1 PRIMARY t2 range idx idx 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
drop table t1,t2;
|
||||
set optimizer_switch= @tmp_mdev12675;
|
||||
#
|
||||
# MDEV-12817: subquery NOT subject to semi-join optimizations
|
||||
# in ON expression of INNER JOIN
|
||||
#
|
||||
CREATE TABLE t1 (c1 int) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2 (c2 int) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (3),(4);
|
||||
CREATE TABLE t3 (c3 int) ENGINE=MyISAM;
|
||||
INSERT INTO t3 VALUES (5),(6);
|
||||
CREATE TABLE t4 (c4 int) ENGINE=MyISAM;
|
||||
INSERT INTO t4 VALUES (7),(8);
|
||||
SELECT c1
|
||||
FROM t1
|
||||
LEFT JOIN
|
||||
( t2 INNER JOIN t3 ON ( 1 IN ( SELECT c4 FROM t4 ) ) )
|
||||
ON (c1 = c3);
|
||||
c1
|
||||
1
|
||||
2
|
||||
EXPLAIN EXTENDED SELECT c1
|
||||
FROM t1
|
||||
LEFT JOIN
|
||||
( t2 INNER JOIN t3 ON ( 1 IN ( SELECT c4 FROM t4 ) ) )
|
||||
ON (c1 = c3);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
2 SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`c1` AS `c1` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t3`.`c3` = `test`.`t1`.`c1`) and <cache>(<in_optimizer>(1,<exists>(select `test`.`t4`.`c4` from `test`.`t4` where (1 = `test`.`t4`.`c4`)))))) where 1
|
||||
# mdev-12820
|
||||
SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN
|
||||
( ( SELECT * FROM t2 WHERE c2 IN ( SELECT c3 FROM t3 ) ) AS sq INNER JOIN t4 )
|
||||
ON (c1 = c2);
|
||||
c1 c2 c4
|
||||
1 NULL NULL
|
||||
2 NULL NULL
|
||||
EXPLAIN EXTENDED SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN
|
||||
( ( SELECT * FROM t2 WHERE c2 IN ( SELECT c3 FROM t3 ) ) AS sq INNER JOIN t4 )
|
||||
ON (c1 = c2);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00
|
||||
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t4`.`c4` AS `c4` from `test`.`t1` left join (`test`.`t2` join `test`.`t4`) on(((`test`.`t2`.`c2` = `test`.`t1`.`c1`) and <in_optimizer>(`test`.`t1`.`c1`,<exists>(select `test`.`t3`.`c3` from `test`.`t3` where (<cache>(`test`.`t2`.`c2`) = `test`.`t3`.`c3`))))) where 1
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
|
||||
@@ -1556,3 +1556,48 @@ i1
|
||||
DROP TABLE t1,t2,t3;
|
||||
set join_cache_level= @save_join_cache_level;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
#
|
||||
# mdev-7791: materialization of a semi-join subquery +
|
||||
# RAND() in WHERE
|
||||
# (materialized table is accessed last)
|
||||
#
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='materialization=on';
|
||||
create table t1(i int);
|
||||
insert into t1 values (1), (2), (3), (7), (9), (10);
|
||||
create table t2(i int);
|
||||
insert into t2 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
|
||||
select * from t1 where (rand() < 0) and i in (select i from t2);
|
||||
i
|
||||
explain extended
|
||||
select * from t1 where (rand() < 0) and i in (select i from t2);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join (`test`.`t2`) where ((rand() < 0))
|
||||
drop table t1,t2;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
#
|
||||
# mdev-12855: materialization of a semi-join subquery + ORDER BY
|
||||
#
|
||||
CREATE TABLE t1 (f1 varchar(8), KEY(f1)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES ('qux'),('foo');
|
||||
CREATE TABLE t2 (f2 varchar(8)) ENGINE=InnoDB;
|
||||
INSERT INTO t2 VALUES ('bar'),('foo'),('qux');
|
||||
SELECT f1 FROM t1
|
||||
WHERE f1 IN ( SELECT f2 FROM t2 WHERE f2 > 'bar' )
|
||||
HAVING f1 != 'foo'
|
||||
ORDER BY f1;
|
||||
f1
|
||||
qux
|
||||
explain SELECT f1 FROM t1
|
||||
WHERE f1 IN ( SELECT f2 FROM t2 WHERE f2 > 'bar' )
|
||||
HAVING f1 != 'foo'
|
||||
ORDER BY f1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 index f1 f1 11 NULL 2 Using index
|
||||
1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 11 func 1
|
||||
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
@@ -1663,9 +1663,9 @@ CREATE VIEW v1 AS SELECT 1;
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <derived3> system NULL NULL NULL NULL 1
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
|
||||
2 MATERIALIZED <derived3> system NULL NULL NULL NULL 1
|
||||
3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
|
||||
SELECT * FROM t1 INNER JOIN t2 ON t2.a != 0 AND t2.a IN (SELECT * FROM v1);
|
||||
a a
|
||||
@@ -3074,6 +3074,99 @@ project_number
|
||||
aaa
|
||||
drop table t1, t2, t3;
|
||||
set optimizer_switch= @tmp_mdev6859;
|
||||
#
|
||||
# MDEV-12675: subquery subject to semi-join optimizations
|
||||
# in ON expression of INNER JOIN
|
||||
#
|
||||
set @tmp_mdev12675=@@optimizer_switch;
|
||||
set optimizer_switch=default;
|
||||
create table t1 (a int) engine=myisam;
|
||||
insert into t1 values (5),(3),(2),(7),(2),(5),(1);
|
||||
create table t2 (b int, index idx(b)) engine=myisam;
|
||||
insert into t2 values (2),(3),(2),(1),(3),(4);
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
analyze table t1,t2;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
test.t2 analyze status OK
|
||||
explain
|
||||
select a from t1, t2 where b between 1 and 2 and a in (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where
|
||||
1 PRIMARY t2 ref idx idx 5 test.t1.a 256 Using index; FirstMatch(t1)
|
||||
1 PRIMARY t2 range idx idx 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
explain
|
||||
select a from t1 join t2 on b between 1 and 2 and a in (select b from t2);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using where
|
||||
1 PRIMARY t2 ref idx idx 5 test.t1.a 256 Using index; FirstMatch(t1)
|
||||
1 PRIMARY t2 range idx idx 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
|
||||
drop table t1,t2;
|
||||
set optimizer_switch= @tmp_mdev12675;
|
||||
#
|
||||
# MDEV-12817: subquery NOT subject to semi-join optimizations
|
||||
# in ON expression of INNER JOIN
|
||||
#
|
||||
CREATE TABLE t1 (c1 int) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
CREATE TABLE t2 (c2 int) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (3),(4);
|
||||
CREATE TABLE t3 (c3 int) ENGINE=MyISAM;
|
||||
INSERT INTO t3 VALUES (5),(6);
|
||||
CREATE TABLE t4 (c4 int) ENGINE=MyISAM;
|
||||
INSERT INTO t4 VALUES (7),(8);
|
||||
SELECT c1
|
||||
FROM t1
|
||||
LEFT JOIN
|
||||
( t2 INNER JOIN t3 ON ( 1 IN ( SELECT c4 FROM t4 ) ) )
|
||||
ON (c1 = c3);
|
||||
c1
|
||||
1
|
||||
2
|
||||
EXPLAIN EXTENDED SELECT c1
|
||||
FROM t1
|
||||
LEFT JOIN
|
||||
( t2 INNER JOIN t3 ON ( 1 IN ( SELECT c4 FROM t4 ) ) )
|
||||
ON (c1 = c3);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
|
||||
2 SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`c1` AS `c1` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t3`.`c3` = `test`.`t1`.`c1`) and <cache>(<in_optimizer>(1,<exists>(select `test`.`t4`.`c4` from `test`.`t4` where (1 = `test`.`t4`.`c4`)))))) where 1
|
||||
# mdev-12820
|
||||
SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN
|
||||
( ( SELECT * FROM t2 WHERE c2 IN ( SELECT c3 FROM t3 ) ) AS sq INNER JOIN t4 )
|
||||
ON (c1 = c2);
|
||||
c1 c2 c4
|
||||
1 NULL NULL
|
||||
2 NULL NULL
|
||||
EXPLAIN EXTENDED SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN
|
||||
( ( SELECT * FROM t2 WHERE c2 IN ( SELECT c3 FROM t3 ) ) AS sq INNER JOIN t4 )
|
||||
ON (c1 = c2);
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
|
||||
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (incremental, BNL join)
|
||||
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t1`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t4`.`c4` AS `c4` from `test`.`t1` left join (`test`.`t2` join `test`.`t4`) on(((`test`.`t2`.`c2` = `test`.`t1`.`c1`) and <in_optimizer>(`test`.`t1`.`c1`,<exists>(select `test`.`t3`.`c3` from `test`.`t3` where (<cache>(`test`.`t2`.`c2`) = `test`.`t3`.`c3`))))) where 1
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
#
|
||||
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
|
||||
|
||||
@@ -2312,4 +2312,92 @@ pk f1 sq
|
||||
5 3 5
|
||||
set optimizer_switch= @save_optimizer_switch;
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# mdev-12838: scan of materialized of semi-join subquery in join
|
||||
#
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
CREATE TABLE t1 (
|
||||
dispatch_group varchar(32),
|
||||
assignment_group varchar(32),
|
||||
sys_id char(32),
|
||||
PRIMARY KEY (sys_id),
|
||||
KEY idx1 (dispatch_group),
|
||||
KEY idx2 (assignment_group)
|
||||
) ENGINE=MyISAM;
|
||||
CREATE TABLE t2 (
|
||||
ugroup varchar(32),
|
||||
user varchar(32),
|
||||
sys_id char(32),
|
||||
PRIMARY KEY (sys_id),
|
||||
KEY idx3 (ugroup),
|
||||
KEY idx4 (user)
|
||||
) ENGINE=MyISAM;
|
||||
CREATE TABLE t3 (
|
||||
type mediumtext,
|
||||
sys_id char(32),
|
||||
PRIMARY KEY (sys_id)
|
||||
) ENGINE=MyISAM;
|
||||
set optimizer_switch='materialization=off';
|
||||
explain SELECT t1.assignment_group
|
||||
FROM t1, t3
|
||||
WHERE t1.assignment_group = t3.sys_id AND
|
||||
t1.dispatch_group IN
|
||||
(SELECT t2.ugroup
|
||||
FROM t2, t3 t3_i
|
||||
WHERE t2.ugroup = t3_i.sys_id AND
|
||||
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
|
||||
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where; Start temporary
|
||||
1 PRIMARY t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where
|
||||
1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t3_i.sys_id 2 Using index condition; Using where; End temporary
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 32 test.t1.assignment_group 1 Using where; Using index
|
||||
SELECT t1.assignment_group
|
||||
FROM t1, t3
|
||||
WHERE t1.assignment_group = t3.sys_id AND
|
||||
t1.dispatch_group IN
|
||||
(SELECT t2.ugroup
|
||||
FROM t2, t3 t3_i
|
||||
WHERE t2.ugroup = t3_i.sys_id AND
|
||||
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
|
||||
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
|
||||
assignment_group
|
||||
df50316637232000158bbfc8bcbe5d23
|
||||
e08fad2637232000158bbfc8bcbe5d39
|
||||
ec70316637232000158bbfc8bcbe5d60
|
||||
7b10fd2637232000158bbfc8bcbe5d30
|
||||
ebb4620037332000158bbfc8bcbe5d89
|
||||
set optimizer_switch='materialization=on';
|
||||
explain SELECT t1.assignment_group
|
||||
FROM t1, t3
|
||||
WHERE t1.assignment_group = t3.sys_id AND
|
||||
t1.dispatch_group IN
|
||||
(SELECT t2.ugroup
|
||||
FROM t2, t3 t3_i
|
||||
WHERE t2.ugroup = t3_i.sys_id AND
|
||||
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
|
||||
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2
|
||||
1 PRIMARY t1 ref idx1,idx2 idx1 35 test.t2.ugroup 2 Using where
|
||||
1 PRIMARY t3 eq_ref PRIMARY PRIMARY 32 test.t1.assignment_group 1 Using where; Using index
|
||||
2 MATERIALIZED t2 ref idx3,idx4 idx4 35 const 2 Using index condition; Using where
|
||||
2 MATERIALIZED t3_i eq_ref PRIMARY PRIMARY 32 test.t2.ugroup 1 Using index condition; Using where
|
||||
SELECT t1.assignment_group
|
||||
FROM t1, t3
|
||||
WHERE t1.assignment_group = t3.sys_id AND
|
||||
t1.dispatch_group IN
|
||||
(SELECT t2.ugroup
|
||||
FROM t2, t3 t3_i
|
||||
WHERE t2.ugroup = t3_i.sys_id AND
|
||||
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
|
||||
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
|
||||
assignment_group
|
||||
df50316637232000158bbfc8bcbe5d23
|
||||
e08fad2637232000158bbfc8bcbe5d39
|
||||
ec70316637232000158bbfc8bcbe5d60
|
||||
7b10fd2637232000158bbfc8bcbe5d30
|
||||
ebb4620037332000158bbfc8bcbe5d89
|
||||
DROP TABLE t1,t2,t3;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
# End of 5.5 tests
|
||||
|
||||
@@ -1978,3 +1978,21 @@ d
|
||||
2016-06-04 00:00:00
|
||||
drop table t1;
|
||||
End of 5.0 tests
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (1,1),(2,2),(3,3);
|
||||
create table t2 (c varchar(30), d varchar(30));
|
||||
insert into t1 values ('1','1'),('2','2'),('4','4');
|
||||
create table t3 (e int, f int);
|
||||
insert into t3 values (1,1),(2,2),(31,31),(32,32);
|
||||
select e,f, (e , f) in (select e,b from t1 union select c,d from t2) as sub from t3;
|
||||
e f sub
|
||||
1 1 1
|
||||
2 2 1
|
||||
31 31 0
|
||||
32 32 0
|
||||
select avg(f), (e , f) in (select e,b from t1 union select c,d from t2) as sub from t3 group by sub;
|
||||
avg(f) sub
|
||||
31.5000 0
|
||||
1.5000 1
|
||||
drop table t1,t2,t3;
|
||||
End of 5.5 tests
|
||||
|
||||
@@ -5618,6 +5618,20 @@ Warnings:
|
||||
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t3`.`e` AS `e`,`test`.`t3`.`f` AS `f` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`c` = `test`.`t1`.`b`) and (`test`.`t3`.`f` = `test`.`t1`.`a`) and (`test`.`t2`.`d` = `test`.`t3`.`e`) and (`test`.`t1`.`a` is not null) and (`test`.`t1`.`a` is not null) and (`test`.`t1`.`b` is not null))) where (`test`.`t1`.`a` < 5)
|
||||
drop view v1;
|
||||
drop table t1,t2,t3;
|
||||
#
|
||||
# MDEV-11240: Server crashes in check_view_single_update or
|
||||
# Assertion `derived->table' failed in mysql_derived_merge_for_insert
|
||||
#
|
||||
CREATE TABLE t3 (a INT);
|
||||
CREATE ALGORITHM = MERGE VIEW v1 AS SELECT t2.a FROM t3 AS t1, t3 AS t2;
|
||||
CREATE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM v1;
|
||||
PREPARE stmt FROM 'REPLACE INTO v2 SELECT a FROM t3';
|
||||
EXECUTE stmt;
|
||||
ERROR HY000: Can not insert into join view 'test.v2' without fields list
|
||||
EXECUTE stmt;
|
||||
ERROR HY000: Can not insert into join view 'test.v2' without fields list
|
||||
drop view v1,v2;
|
||||
drop table t3;
|
||||
# -----------------------------------------------------------------
|
||||
# -- End of 5.5 tests.
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
@@ -9,19 +9,19 @@
|
||||
<table_data name="t1">
|
||||
<row>
|
||||
<field name="a">1</field>
|
||||
<field name="b">b1</field>
|
||||
<field name="b"> b1</field>
|
||||
</row>
|
||||
<row>
|
||||
<field name="a">2</field>
|
||||
<field name="b">b2</field>
|
||||
<field name="b"> b2</field>
|
||||
</row>
|
||||
<row>
|
||||
<field name="a">3</field>
|
||||
<field name="b">b3</field>
|
||||
<field name="b"> b3</field>
|
||||
</row>
|
||||
<row>
|
||||
<field name="a">11</field>
|
||||
<field name="b">b11</field>
|
||||
<field name="b"> b11</field>
|
||||
</row>
|
||||
|
||||
<!-- Check field values as tags -->
|
||||
|
||||
33
mysql-test/suite/parts/r/longname.result
Normal file
33
mysql-test/suite/parts/r/longname.result
Normal file
@@ -0,0 +1,33 @@
|
||||
set names utf8;
|
||||
create database mysqltest1;
|
||||
CREATE TABLE mysqltest1.test_jfg_table_name_with_64_chars_123456789012345678901234567890 (
|
||||
id int(10) unsigned NOT NULL,
|
||||
id2 int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY ( id, id2 )
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
|
||||
PARTITION BY RANGE ( id )
|
||||
SUBPARTITION BY HASH ( id2 )
|
||||
SUBPARTITIONS 2 (
|
||||
PARTITION test_jfg_partition_name_with_60_chars_1234567890123456789012 VALUES LESS THAN (1000) ENGINE = InnoDB,
|
||||
PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
|
||||
Warnings:
|
||||
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table.
|
||||
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
|
||||
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table.
|
||||
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
|
||||
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table.
|
||||
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
|
||||
Warning 1478 InnoDB: ROW_FORMAT=DYNAMIC requires innodb_file_per_table.
|
||||
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
|
||||
CREATE TABLE mysqltest1.éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé (
|
||||
id int(10) unsigned NOT NULL,
|
||||
id2 int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY ( id, id2 )
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
|
||||
PARTITION BY RANGE ( id )
|
||||
SUBPARTITION BY HASH ( id2 )
|
||||
SUBPARTITIONS 2 (
|
||||
PARTITION çççççççççççççççççççççççççççççççççççççççççççççççççççççççççççç VALUES LESS THAN (1000) ENGINE = InnoDB,
|
||||
PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
|
||||
ERROR HY000: The path specified for @0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@0n@ is too long.
|
||||
drop database mysqltest1;
|
||||
6
mysql-test/suite/parts/r/quoting.result
Normal file
6
mysql-test/suite/parts/r/quoting.result
Normal file
@@ -0,0 +1,6 @@
|
||||
set sql_mode=ansi_quotes;
|
||||
create table t1 (i int) partition by range (i) (partition flush values less than maxvalue);
|
||||
set sql_mode=default;
|
||||
lock tables t1 read local;
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
29
mysql-test/suite/parts/t/longname.test
Normal file
29
mysql-test/suite/parts/t/longname.test
Normal file
@@ -0,0 +1,29 @@
|
||||
source include/have_innodb.inc;
|
||||
source include/have_partition.inc;
|
||||
set names utf8;
|
||||
|
||||
create database mysqltest1;
|
||||
CREATE TABLE mysqltest1.test_jfg_table_name_with_64_chars_123456789012345678901234567890 (
|
||||
id int(10) unsigned NOT NULL,
|
||||
id2 int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY ( id, id2 )
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
|
||||
PARTITION BY RANGE ( id )
|
||||
SUBPARTITION BY HASH ( id2 )
|
||||
SUBPARTITIONS 2 (
|
||||
PARTITION test_jfg_partition_name_with_60_chars_1234567890123456789012 VALUES LESS THAN (1000) ENGINE = InnoDB,
|
||||
PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
|
||||
|
||||
--error ER_PATH_LENGTH
|
||||
CREATE TABLE mysqltest1.éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé (
|
||||
id int(10) unsigned NOT NULL,
|
||||
id2 int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY ( id, id2 )
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
|
||||
PARTITION BY RANGE ( id )
|
||||
SUBPARTITION BY HASH ( id2 )
|
||||
SUBPARTITIONS 2 (
|
||||
PARTITION çççççççççççççççççççççççççççççççççççççççççççççççççççççççççççç VALUES LESS THAN (1000) ENGINE = InnoDB,
|
||||
PARTITION pmax VALUES LESS THAN MAXVALUE ENGINE = InnoDB);
|
||||
|
||||
drop database mysqltest1;
|
||||
10
mysql-test/suite/parts/t/quoting.test
Normal file
10
mysql-test/suite/parts/t/quoting.test
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
# MDEV-13017 LOCK TABLE fails with irrelevant error while working with tables affected by ANSI_QUOTES
|
||||
#
|
||||
--source include/have_partition.inc
|
||||
set sql_mode=ansi_quotes;
|
||||
create table t1 (i int) partition by range (i) (partition flush values less than maxvalue);
|
||||
set sql_mode=default;
|
||||
lock tables t1 read local;
|
||||
unlock tables;
|
||||
drop table t1;
|
||||
4
mysql-test/suite/perfschema/include/have_timer_cycle.inc
Normal file
4
mysql-test/suite/perfschema/include/have_timer_cycle.inc
Normal file
@@ -0,0 +1,4 @@
|
||||
if (!`SELECT count(*) FROM performance_schema.performance_timers WHERE timer_name='CYCLE' AND timer_frequency IS NOT NULL`)
|
||||
{
|
||||
Skip Need performance timer CYCLE;
|
||||
}
|
||||
@@ -554,7 +554,7 @@ ERROR 42000: DROP command denied to user 'pfs_user_4'@'localhost' for table 'eve
|
||||
#
|
||||
# Grant access to change tables with the root account
|
||||
GRANT UPDATE ON performance_schema.setup_consumers TO pfs_user_4;
|
||||
GRANT UPDATE ON performance_schema.setup_timers TO pfs_user_4;
|
||||
GRANT UPDATE, SELECT ON performance_schema.setup_timers TO pfs_user_4;
|
||||
GRANT UPDATE, SELECT ON performance_schema.setup_instruments TO pfs_user_4;
|
||||
GRANT DROP ON performance_schema.events_waits_current TO pfs_user_4;
|
||||
GRANT DROP ON performance_schema.events_waits_history TO pfs_user_4;
|
||||
@@ -565,7 +565,7 @@ UPDATE performance_schema.setup_instruments SET enabled = 'YES'
|
||||
WHERE name LIKE 'wait/synch/mutex/%'
|
||||
OR name LIKE 'wait/synch/rwlock/%';
|
||||
UPDATE performance_schema.setup_consumers SET enabled = 'YES';
|
||||
UPDATE performance_schema.setup_timers SET timer_name = 'TICK';
|
||||
UPDATE performance_schema.setup_timers SET timer_name = 'TICK' WHERE name <> "wait";
|
||||
TRUNCATE TABLE performance_schema.events_waits_history_long;
|
||||
TRUNCATE TABLE performance_schema.events_waits_history;
|
||||
TRUNCATE TABLE performance_schema.events_waits_current;
|
||||
@@ -575,4 +575,6 @@ DROP USER pfs_user_4;
|
||||
flush privileges;
|
||||
UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';
|
||||
UPDATE performance_schema.setup_consumers SET enabled = 'YES';
|
||||
UPDATE performance_schema.setup_timers SET timer_name = 'CYCLE';
|
||||
UPDATE performance_schema.setup_timers SET timer_name = 'MICROSECOND' where name="idle";
|
||||
UPDATE performance_schema.setup_timers SET timer_name = 'NANOSECOND' where name="stage";
|
||||
UPDATE performance_schema.setup_timers SET timer_name = 'NANOSECOND' where name="statement";
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
--source include/not_embedded.inc
|
||||
--source include/have_perfschema.inc
|
||||
--source include/have_timer_cycle.inc
|
||||
|
||||
--replace_column 2 <frequency> 3 <resolution> 4 <overhead>
|
||||
select * from performance_schema.performance_timers;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
--source include/not_embedded.inc
|
||||
--source include/have_perfschema.inc
|
||||
--source include/have_timer_cycle.inc
|
||||
|
||||
select * from performance_schema.setup_timers;
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ TRUNCATE TABLE performance_schema.events_waits_current;
|
||||
--echo # Grant access to change tables with the root account
|
||||
|
||||
GRANT UPDATE ON performance_schema.setup_consumers TO pfs_user_4;
|
||||
GRANT UPDATE ON performance_schema.setup_timers TO pfs_user_4;
|
||||
GRANT UPDATE, SELECT ON performance_schema.setup_timers TO pfs_user_4;
|
||||
GRANT UPDATE, SELECT ON performance_schema.setup_instruments TO pfs_user_4;
|
||||
GRANT DROP ON performance_schema.events_waits_current TO pfs_user_4;
|
||||
GRANT DROP ON performance_schema.events_waits_history TO pfs_user_4;
|
||||
@@ -308,7 +308,11 @@ WHERE name LIKE 'wait/synch/mutex/%'
|
||||
|
||||
UPDATE performance_schema.setup_consumers SET enabled = 'YES';
|
||||
|
||||
UPDATE performance_schema.setup_timers SET timer_name = 'TICK';
|
||||
# We do not touch "wait", to avoid restoring it at the end of the test,
|
||||
# as its default value initialized at server startup is ambiguous:
|
||||
# it can be CYCLE or NANOSECOND depending on platform
|
||||
|
||||
UPDATE performance_schema.setup_timers SET timer_name = 'TICK' WHERE name <> "wait";
|
||||
|
||||
TRUNCATE TABLE performance_schema.events_waits_history_long;
|
||||
TRUNCATE TABLE performance_schema.events_waits_history;
|
||||
@@ -323,5 +327,9 @@ DROP USER pfs_user_4;
|
||||
flush privileges;
|
||||
UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES';
|
||||
UPDATE performance_schema.setup_consumers SET enabled = 'YES';
|
||||
UPDATE performance_schema.setup_timers SET timer_name = 'CYCLE';
|
||||
|
||||
# Restore the default values for the timers that we changed.
|
||||
# Note, we did not touch "wait", see above.
|
||||
UPDATE performance_schema.setup_timers SET timer_name = 'MICROSECOND' where name="idle";
|
||||
UPDATE performance_schema.setup_timers SET timer_name = 'NANOSECOND' where name="stage";
|
||||
UPDATE performance_schema.setup_timers SET timer_name = 'NANOSECOND' where name="statement";
|
||||
|
||||
17
mysql-test/suite/rpl/r/rpl_mdev-11092.result
Normal file
17
mysql-test/suite/rpl/r/rpl_mdev-11092.result
Normal file
@@ -0,0 +1,17 @@
|
||||
include/master-slave.inc
|
||||
[connection master]
|
||||
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
|
||||
call mtr.add_suppression("Slave SQL: The incident LOST_EVENTS occured on the master. .*");
|
||||
SET GLOBAL max_binlog_cache_size = 4096;
|
||||
SET GLOBAL binlog_cache_size = 4096;
|
||||
SET GLOBAL max_binlog_stmt_cache_size = 4096;
|
||||
SET GLOBAL binlog_stmt_cache_size = 4096;
|
||||
CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MYISAM;
|
||||
ERROR HY000: Writing one row to the row-based binary log failed
|
||||
include/wait_for_slave_sql_error_and_skip.inc [errno=1590]
|
||||
SET GLOBAL max_binlog_cache_size= ORIGINAL_VALUE;
|
||||
SET GLOBAL binlog_cache_size= ORIGINAL_VALUE;
|
||||
SET GLOBAL max_binlog_stmt_cache_size= ORIGINAL_VALUE;
|
||||
SET GLOBAL binlog_stmt_cache_size= ORIGINAL_VALUE;
|
||||
DROP TABLE t1;
|
||||
include/rpl_end.inc
|
||||
29
mysql-test/suite/rpl/r/rpl_reset_slave_fail.result
Normal file
29
mysql-test/suite/rpl/r/rpl_reset_slave_fail.result
Normal file
@@ -0,0 +1,29 @@
|
||||
include/master-slave.inc
|
||||
[connection master]
|
||||
CREATE TABLE t1 (c1 INT);
|
||||
INSERT INTO t1 (c1) VALUES (1);
|
||||
include/stop_slave_sql.inc
|
||||
FLUSH LOGS;
|
||||
FLUSH LOGS;
|
||||
INSERT INTO t1 (c1) VALUES (2);
|
||||
include/sync_slave_io_with_master.inc
|
||||
call mtr.add_suppression("File '.*slave-relay-bin.");
|
||||
call mtr.add_suppression("Could not open log file");
|
||||
call mtr.add_suppression("Failed to open the relay log");
|
||||
call mtr.add_suppression("Failed to initialize the master info structure");
|
||||
include/rpl_stop_server.inc [server_number=2]
|
||||
# Removing file(s)
|
||||
include/rpl_start_server.inc [server_number=2]
|
||||
START SLAVE;
|
||||
ERROR HY000: Could not initialize master info structure; more error messages can be found in the MariaDB error log
|
||||
START SLAVE;
|
||||
ERROR HY000: Could not initialize master info structure; more error messages can be found in the MariaDB error log
|
||||
RESET SLAVE;
|
||||
DROP TABLE t1;
|
||||
START SLAVE UNTIL MASTER_LOG_FILE= 'MASTER_LOG_FILE', MASTER_LOG_POS= MASTER_LOG_POS;;
|
||||
include/wait_for_slave_sql_to_stop.inc
|
||||
include/stop_slave_io.inc
|
||||
include/start_slave.inc
|
||||
include/diff_tables.inc [master:t1, slave:t1]
|
||||
DROP TABLE t1;
|
||||
include/rpl_end.inc
|
||||
1
mysql-test/suite/rpl/t/rpl_mdev-11092.opt
Normal file
1
mysql-test/suite/rpl/t/rpl_mdev-11092.opt
Normal file
@@ -0,0 +1 @@
|
||||
--binlog_checksum=1 --binlog-annotate-row-events=1
|
||||
53
mysql-test/suite/rpl/t/rpl_mdev-11092.test
Normal file
53
mysql-test/suite/rpl/t/rpl_mdev-11092.test
Normal file
@@ -0,0 +1,53 @@
|
||||
--source include/have_innodb.inc
|
||||
--source include/master-slave.inc
|
||||
--source include/not_embedded.inc
|
||||
--source include/not_windows.inc
|
||||
--source include/have_binlog_format_row.inc
|
||||
|
||||
########################################################################################
|
||||
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
|
||||
call mtr.add_suppression("Slave SQL: The incident LOST_EVENTS occured on the master. .*");
|
||||
|
||||
let $old_max_binlog_cache_size= query_get_value(SHOW VARIABLES LIKE "max_binlog_cache_size", Value, 1);
|
||||
let $old_binlog_cache_size= query_get_value(SHOW VARIABLES LIKE "binlog_cache_size", Value, 1);
|
||||
let $old_max_binlog_stmt_cache_size= query_get_value(SHOW VARIABLES LIKE "max_binlog_stmt_cache_size", Value, 1);
|
||||
let $old_binlog_stmt_cache_size= query_get_value(SHOW VARIABLES LIKE "binlog_stmt_cache_size", Value, 1);
|
||||
|
||||
SET GLOBAL max_binlog_cache_size = 4096;
|
||||
SET GLOBAL binlog_cache_size = 4096;
|
||||
SET GLOBAL max_binlog_stmt_cache_size = 4096;
|
||||
SET GLOBAL binlog_stmt_cache_size = 4096;
|
||||
disconnect master;
|
||||
connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
|
||||
|
||||
CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MYISAM;
|
||||
|
||||
let $data = `select concat('"', repeat('a',2000), '"')`;
|
||||
|
||||
connection master;
|
||||
|
||||
--disable_query_log
|
||||
--error ER_BINLOG_ROW_LOGGING_FAILED
|
||||
eval INSERT INTO t1 (a, data) VALUES (2,
|
||||
CONCAT($data, $data, $data, $data, $data, $data));
|
||||
--enable_query_log
|
||||
|
||||
# Incident event
|
||||
# 1590=ER_SLAVE_INCIDENT
|
||||
--let $slave_sql_errno= 1590
|
||||
--source include/wait_for_slave_sql_error_and_skip.inc
|
||||
|
||||
connection master;
|
||||
|
||||
--replace_result $old_max_binlog_cache_size ORIGINAL_VALUE
|
||||
--eval SET GLOBAL max_binlog_cache_size= $old_max_binlog_cache_size
|
||||
--replace_result $old_binlog_cache_size ORIGINAL_VALUE
|
||||
--eval SET GLOBAL binlog_cache_size= $old_binlog_cache_size
|
||||
--replace_result $old_max_binlog_stmt_cache_size ORIGINAL_VALUE
|
||||
--eval SET GLOBAL max_binlog_stmt_cache_size= $old_max_binlog_stmt_cache_size
|
||||
--replace_result $old_binlog_stmt_cache_size ORIGINAL_VALUE
|
||||
--eval SET GLOBAL binlog_stmt_cache_size= $old_binlog_stmt_cache_size
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--source include/rpl_end.inc
|
||||
91
mysql-test/suite/rpl/t/rpl_reset_slave_fail.test
Normal file
91
mysql-test/suite/rpl/t/rpl_reset_slave_fail.test
Normal file
@@ -0,0 +1,91 @@
|
||||
###############################################################################
|
||||
# Bug#24901077: RESET SLAVE ALL DOES NOT ALWAYS RESET SLAVE
|
||||
#
|
||||
# Problem:
|
||||
# =======
|
||||
# If you have a relay log index file that has ended up with
|
||||
# some relay log files that do not exists, then RESET SLAVE
|
||||
# ALL is not enough to get back to a clean state.
|
||||
###############################################################################
|
||||
# Remove all slave-relay-bin.0* files (do not remove slave-relay-bin.index)
|
||||
# During server restart rli initialization will fail as there are no
|
||||
# relay logs. In case of bug RESET SLAVE will not do the required clean up
|
||||
# as rli is not inited and subsequent START SLAVE will fail.
|
||||
# Disable "Warning 1612 Being purged log ./slave-relay-bin.0* was not found"
|
||||
# because it is different on Unix and Windows systems.
|
||||
|
||||
--source include/have_binlog_format_mixed.inc
|
||||
--source include/master-slave.inc
|
||||
|
||||
--connection master
|
||||
CREATE TABLE t1 (c1 INT);
|
||||
INSERT INTO t1 (c1) VALUES (1);
|
||||
--sync_slave_with_master
|
||||
|
||||
--connection slave
|
||||
--source include/stop_slave_sql.inc
|
||||
--let $MYSQLD_SLAVE_DATADIR= `select @@datadir`
|
||||
|
||||
--connection master
|
||||
# Generate more relay logs on slave.
|
||||
FLUSH LOGS;
|
||||
FLUSH LOGS;
|
||||
INSERT INTO t1 (c1) VALUES (2);
|
||||
|
||||
--source include/sync_slave_io_with_master.inc
|
||||
call mtr.add_suppression("File '.*slave-relay-bin.");
|
||||
call mtr.add_suppression("Could not open log file");
|
||||
call mtr.add_suppression("Failed to open the relay log");
|
||||
call mtr.add_suppression("Failed to initialize the master info structure");
|
||||
|
||||
# Stop slave
|
||||
--let $rpl_server_number= 2
|
||||
--source include/rpl_stop_server.inc
|
||||
|
||||
# Delete file(s)
|
||||
--echo # Removing $remove_pattern file(s)
|
||||
--let $remove_pattern= slave-relay-bin.0*
|
||||
--remove_files_wildcard $MYSQLD_SLAVE_DATADIR $remove_pattern
|
||||
|
||||
# Start slave
|
||||
--let $rpl_server_number= 2
|
||||
--source include/rpl_start_server.inc
|
||||
|
||||
# Start slave must fail because of the removed file(s).
|
||||
--error ER_MASTER_INFO
|
||||
START SLAVE;
|
||||
|
||||
# Try a second time, it must fail again.
|
||||
--error ER_MASTER_INFO
|
||||
START SLAVE;
|
||||
|
||||
# Retrieve master executed position before reset slave.
|
||||
--let $master_exec_file= query_get_value("SHOW SLAVE STATUS", Relay_Master_Log_File, 1)
|
||||
--let $master_exec_pos= query_get_value("SHOW SLAVE STATUS", Exec_Master_Log_Pos, 1)
|
||||
|
||||
# Reset slave.
|
||||
# Disable "Warning 1612 Being purged log ./slave-relay-bin.0* was not found"
|
||||
# because it is different on Unix and Windows systems.
|
||||
--disable_warnings
|
||||
RESET SLAVE;
|
||||
--enable_warnings
|
||||
DROP TABLE t1;
|
||||
--replace_result $master_exec_file MASTER_LOG_FILE $master_exec_pos MASTER_LOG_POS
|
||||
--eval START SLAVE UNTIL MASTER_LOG_FILE= '$master_exec_file', MASTER_LOG_POS= $master_exec_pos;
|
||||
--source include/wait_for_slave_sql_to_stop.inc
|
||||
--source include/stop_slave_io.inc
|
||||
|
||||
# Start slave.
|
||||
--source include/start_slave.inc
|
||||
|
||||
--connection master
|
||||
--sync_slave_with_master
|
||||
# Check consistency.
|
||||
--let $diff_tables= master:t1, slave:t1
|
||||
--source include/diff_tables.inc
|
||||
|
||||
# Cleanup
|
||||
--connection master
|
||||
DROP TABLE t1;
|
||||
--sync_slave_with_master
|
||||
--source include/rpl_end.inc
|
||||
76
mysql-test/t/binary_to_hex.test
Normal file
76
mysql-test/t/binary_to_hex.test
Normal file
@@ -0,0 +1,76 @@
|
||||
# === Purpose ===
|
||||
# The purpose of this test case is to make
|
||||
# sure that the binary data in tables is printed
|
||||
# as hex when the option binary-as-hex is enabled.
|
||||
#
|
||||
# === Related bugs and/or worklogs ===
|
||||
# Bug #25340722 - PRINT BINARY DATA AS HEX IN THE MYSQL
|
||||
# CLIENT (CONTRIBUTION)
|
||||
#
|
||||
|
||||
# Save the initial number of concurrent sessions
|
||||
--source include/count_sessions.inc
|
||||
--source include/not_embedded.inc
|
||||
|
||||
USE test;
|
||||
--disable_warnings
|
||||
DROP TABLE IF EXISTS t1, t2;
|
||||
--enable_warnings
|
||||
|
||||
CREATE TABLE t1 (c1 TINYBLOB,
|
||||
c2 BLOB,
|
||||
c3 MEDIUMBLOB,
|
||||
c4 LONGBLOB,
|
||||
c5 TEXT,
|
||||
c6 BIT(1),
|
||||
c7 CHAR,
|
||||
c8 VARCHAR(10),
|
||||
c9 GEOMETRY) CHARACTER SET = binary;
|
||||
|
||||
SHOW CREATE TABLE t1;
|
||||
|
||||
INSERT INTO t1 VALUES ('tinyblob-text readable', 'blob-text readable',
|
||||
'mediumblob-text readable', 'longblob-text readable',
|
||||
'text readable', b'1', 'c', 'variable',
|
||||
POINT(1, 1));
|
||||
|
||||
CREATE TABLE t2(id int, `col1` binary(10),`col2` blob);
|
||||
|
||||
SHOW CREATE TABLE t2;
|
||||
|
||||
INSERT INTO t2 VALUES (1, X'AB1234', X'123ABC'), (2, X'DE1234', X'123DEF');
|
||||
|
||||
--echo #Print the table contents when binary-as-hex option is off.
|
||||
--replace_column 6 # 9 #
|
||||
SELECT * FROM t1;
|
||||
|
||||
--replace_column 2 # 3 #
|
||||
SELECT * FROM t2;
|
||||
|
||||
--echo #Print the table contents after turning on the binary-as-hex option
|
||||
--echo
|
||||
--echo #Print the table contents in tab format
|
||||
--echo
|
||||
--exec $MYSQL test --binary-as-hex -e "SELECT * FROM t1; SELECT * FROM t2;"
|
||||
--echo
|
||||
--echo #Print the table contents in table format
|
||||
--echo
|
||||
--exec $MYSQL test --binary-as-hex --table -e "SELECT * FROM t1; SELECT * FROM t2 WHERE col2=0x123ABC;"
|
||||
--echo
|
||||
--echo #Print the table contents vertically
|
||||
--echo
|
||||
--exec $MYSQL test --binary-as-hex --vertical -e "SELECT * FROM t1;"
|
||||
--echo
|
||||
--echo #Print the table contents in xml format
|
||||
--echo
|
||||
--exec $MYSQL test --binary-as-hex --xml -e "SELECT * FROM t1; SELECT * FROM t2;"
|
||||
--echo
|
||||
--echo #Print the table contents in html format
|
||||
--echo
|
||||
--exec $MYSQL test --binary-as-hex --html -e "SELECT * FROM t1; SELECT * FROM t2;"
|
||||
|
||||
#Cleanup
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
# Wait till all disconnects are completed
|
||||
--source include/wait_until_count_sessions.inc
|
||||
@@ -60,4 +60,10 @@ SHOW VARIABLES LIKE 'have_innodb';
|
||||
SELECT 'bug' as '' FROM INFORMATION_SCHEMA.ENGINES WHERE engine='innodb'
|
||||
and SUPPORT='YES';
|
||||
|
||||
#
|
||||
# MDEV-13063 Server crashes in intern_plugin_lock or assertion `plugin_ptr->ref_count == 1' fails in plugin_init
|
||||
#
|
||||
--error 1
|
||||
--exec $MYSQLD_BOOTSTRAP_CMD --myisam_recover_options=NONE
|
||||
|
||||
--echo End of 5.5 tests
|
||||
|
||||
@@ -107,3 +107,19 @@ create view v1 as select * from t1;
|
||||
select count(distinct i) from v1;
|
||||
drop table t1;
|
||||
drop view v1;
|
||||
|
||||
#
|
||||
# MDEV-12136 SELECT COUNT(DISTINCT) returns the wrong value when tmp_table_size is limited
|
||||
#
|
||||
create table t1 (user_id char(64) character set utf8);
|
||||
insert t1 values(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17);
|
||||
set @@tmp_table_size = 1024;
|
||||
select count(distinct user_id) from t1;
|
||||
alter table t1 modify user_id char(128) character set utf8;
|
||||
select count(distinct user_id) from t1;
|
||||
drop table t1;
|
||||
set @@tmp_table_size = default;
|
||||
|
||||
#
|
||||
# End of 5.5 tests
|
||||
#
|
||||
|
||||
@@ -1881,6 +1881,56 @@ deallocate prepare stmt1;
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # Bug mdev-12670: mergeable derived / view with subqueries
|
||||
--echo # subject to semi-join optimizations
|
||||
--echo # (actually this is a 5.3 bug.)
|
||||
--echo #
|
||||
|
||||
create table t1 (a int) engine=myisam;
|
||||
insert into t1 values (5),(3),(2),(7),(2),(5),(1);
|
||||
create table t2 (b int, index idx(b)) engine=myisam;
|
||||
insert into t2 values (2),(3),(2),(1),(3),(4);
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
analyze table t1,t2;
|
||||
|
||||
explain select a from t1 where a in (select b from t2);
|
||||
explain select * from (select a from t1 where a in (select b from t2)) t;
|
||||
create view v1 as select a from t1 where a in (select b from t2);
|
||||
explain select * from v1;
|
||||
|
||||
drop view v1;
|
||||
drop table t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # Bug mdev-12812: mergeable derived / view with subqueries
|
||||
--echo # NOT subject to semi-join optimizations
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (c1 varchar(3)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('foo'),('foo');
|
||||
|
||||
CREATE TABLE t2 (c2 varchar(3)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES ('bar'),('qux'),('foo');
|
||||
|
||||
let $q=
|
||||
SELECT STRAIGHT_JOIN *
|
||||
FROM ( SELECT * FROM t1 WHERE c1 IN ( SELECT c2 FROM t2 ) ) AS sq;
|
||||
|
||||
eval $q;
|
||||
eval EXPLAIN EXTENDED $q;
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
# The following command must be the last one the file
|
||||
set optimizer_switch=@exit_optimizer_switch;
|
||||
set join_cache_level=@exit_join_cache_level;
|
||||
|
||||
@@ -1703,6 +1703,44 @@ select a as x from t1 group by x having x > 1;
|
||||
select a from t1 group by a having a > 1;
|
||||
drop table t1;
|
||||
set sql_mode= @save_sql_mode;
|
||||
|
||||
#
|
||||
# MDEV-7826 Server crashes in Item_subselect::enumerate_field_refs_processor
|
||||
#
|
||||
create table t1 (f1 int);
|
||||
insert into t1 values (5),(9);
|
||||
create table t2 (f2 int);
|
||||
insert into t2 values (0),(6);
|
||||
create table t3 (f3 int);
|
||||
insert into t3 values (6),(3);
|
||||
create table t4 (f4 int);
|
||||
insert into t4 values (1),(0);
|
||||
--error ER_ILLEGAL_REFERENCE
|
||||
select
|
||||
(select min(f1) from t1 where f1 in (select min(f4) from t2)) as field7,
|
||||
(select count(*) from t3 where f3 in (select max(f4) from t2 group by field7))
|
||||
from t4;
|
||||
drop table t1, t2, t3, t4;
|
||||
|
||||
#
|
||||
# MDEV-13180 Unused left join causes server crash
|
||||
#
|
||||
create table t1 (i1 int);
|
||||
insert into t1 values (1);
|
||||
create table t2 (i int);
|
||||
insert into t2 values (2);
|
||||
select 1 from t1 left join t2 b on b.i = (select max(b.i) from t2);
|
||||
drop table t1, t2;
|
||||
|
||||
|
||||
#
|
||||
# MDEV-12489 The select stmt may fail due to "having clause is ambiguous" unexpected
|
||||
#
|
||||
create table t1 (c1 int, c2 int);
|
||||
create table t2 (c1 int, c2 int);
|
||||
select t1.c1 as c1, t2.c2 as c1 from t1, t2 where t1.c1 < 20 and t2.c2 > 5 group by t1.c1, t2.c2 having t1.c1 < 3;
|
||||
drop table t1, t2;
|
||||
|
||||
#
|
||||
# End of MariaDB 5.5 tests
|
||||
#
|
||||
|
||||
@@ -1801,4 +1801,86 @@ SELECT * FROM t1 INNER JOIN t2 ON c = b LEFT JOIN t3 ON d = a
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-11958: LEFT JOIN with stored routine produces incorrect result
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t (x INT);
|
||||
INSERT INTO t VALUES(1),(NULL);
|
||||
CREATE FUNCTION f (val INT, ret INT) RETURNS INT DETERMINISTIC RETURN IFNULL(val, ret);
|
||||
|
||||
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
|
||||
FROM t t1 LEFT JOIN t t2
|
||||
ON t1.x = t2.x
|
||||
WHERE IFNULL(t2.x,0)=0;
|
||||
explain extended
|
||||
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
|
||||
FROM t t1 LEFT JOIN t t2
|
||||
ON t1.x = t2.x
|
||||
WHERE IFNULL(t2.x,0)=0;
|
||||
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
|
||||
FROM t t1 LEFT JOIN t t2
|
||||
ON t1.x = t2.x
|
||||
WHERE f(t2.x,0)=0;
|
||||
explain extended
|
||||
SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0)
|
||||
FROM t t1 LEFT JOIN t t2
|
||||
ON t1.x = t2.x
|
||||
WHERE f(t2.x,0)=0;
|
||||
|
||||
drop function f;
|
||||
drop table t;
|
||||
CREATE TABLE t1 (
|
||||
col1 DECIMAL(33,5) NULL DEFAULT NULL,
|
||||
col2 DECIMAL(33,5) NULL DEFAULT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE t2 (
|
||||
col1 DECIMAL(33,5) NULL DEFAULT NULL,
|
||||
col2 DECIMAL(33,5) NULL DEFAULT NULL,
|
||||
col3 DECIMAL(33,5) NULL DEFAULT NULL
|
||||
);
|
||||
|
||||
INSERT INTO t1 VALUES (2, 1.1), (2, 2.1);
|
||||
INSERT INTO t2 VALUES (3, 3.1, 4), (1, 1, NULL);
|
||||
|
||||
DELIMITER |;
|
||||
|
||||
CREATE FUNCTION f1 ( p_num DECIMAL(45,15), p_return DECIMAL(45,15))
|
||||
RETURNS decimal(33,5)
|
||||
LANGUAGE SQL
|
||||
DETERMINISTIC
|
||||
CONTAINS SQL
|
||||
SQL SECURITY INVOKER
|
||||
BEGIN
|
||||
IF p_num IS NULL THEN
|
||||
RETURN p_return;
|
||||
ELSE
|
||||
RETURN p_num;
|
||||
END IF;
|
||||
END |
|
||||
|
||||
DELIMITER ;|
|
||||
|
||||
let $q1=
|
||||
SELECT t1.col1, t2.col1, t2.col3
|
||||
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
|
||||
WHERE IFNULL(t2.col3,0) = 0;
|
||||
|
||||
eval $q1;
|
||||
eval EXPLAIN EXTENDED $q1;
|
||||
|
||||
let $q2=
|
||||
SELECT t1.col1, t2.col1, t2.col3
|
||||
FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2
|
||||
WHERE f1(t2.col3,0) = 0;
|
||||
eval $q2;
|
||||
eval EXPLAIN EXTENDED $q2;
|
||||
|
||||
DROP FUNCTION f1;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo # end of 5.5 tests
|
||||
|
||||
SET optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
@@ -618,3 +618,33 @@ EOF
|
||||
|
||||
--echo
|
||||
--echo End of tests
|
||||
|
||||
#
|
||||
# MDEV-13187 incorrect backslash parsing in clients
|
||||
#
|
||||
create table `a1\``b1` (a int);
|
||||
show tables;
|
||||
insert `a1\``b1` values (1),(2);
|
||||
show create table `a1\``b1`;
|
||||
--exec $MYSQL_DUMP --compact test
|
||||
--exec $MYSQL_DUMP test > $MYSQLTEST_VARDIR/tmp/bug.sql
|
||||
insert `a1\``b1` values (4),(5);
|
||||
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug.sql
|
||||
show create table `a1\``b1`;
|
||||
select * from `a1\``b1`;
|
||||
drop table `a1\``b1`;
|
||||
|
||||
# same with ansi_quotes
|
||||
set sql_mode=ansi_quotes;
|
||||
create table "a1\""b1" (a int);
|
||||
show tables;
|
||||
insert "a1\""b1" values (1),(2);
|
||||
show create table "a1\""b1";
|
||||
--exec $MYSQL_DUMP --compact --compatible=postgres test
|
||||
--exec $MYSQL_DUMP --compatible=postgres test > $MYSQLTEST_VARDIR/tmp/bug.sql
|
||||
insert "a1\""b1" values (4),(5);
|
||||
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug.sql
|
||||
show create table "a1\""b1";
|
||||
select * from "a1\""b1";
|
||||
drop table "a1\""b1";
|
||||
set sql_mode=default;
|
||||
|
||||
@@ -2942,11 +2942,17 @@ disconnect $x;
|
||||
# Disconnect the selected connection
|
||||
disconnect $y;
|
||||
--echo $CURRENT_CONNECTION
|
||||
connection default;
|
||||
|
||||
#
|
||||
# MDEV-13187 incorrect backslash parsing in clients
|
||||
#
|
||||
set sql_mode=no_backslash_escapes;
|
||||
select "foo\""bar";
|
||||
set sql_mode=default;
|
||||
|
||||
--echo End of tests
|
||||
|
||||
connection default;
|
||||
# Wait till we reached the initial number of concurrent sessions
|
||||
--source include/wait_until_count_sessions.inc
|
||||
|
||||
|
||||
@@ -80,6 +80,9 @@ insert into t3 values(1);
|
||||
|
||||
insert into t4 select * from t3;
|
||||
|
||||
--error ER_OPTION_PREVENTS_STATEMENT
|
||||
create table t3 (a int);
|
||||
|
||||
# a non-temp table updated:
|
||||
--error ER_OPTION_PREVENTS_STATEMENT
|
||||
update t1,t3 set t1.a=t3.a+1 where t1.a=t3.a;
|
||||
|
||||
@@ -5998,3 +5998,38 @@ INSERT INTO t1 VALUES ('foo','bar');
|
||||
SELECT * FROM t1 WHERE f2 >= SOME ( SELECT f1 FROM t1 );
|
||||
SELECT * FROM t1 WHERE f2 <= SOME ( SELECT f1 FROM t1 );
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-10146: Wrong result (or questionable result and behavior)
|
||||
--echo # with aggregate function in uncorrelated SELECT subquery
|
||||
--echo #
|
||||
CREATE TABLE t1 (f1 INT);
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
|
||||
CREATE TABLE t2 (f2 int);
|
||||
|
||||
INSERT INTO t2 VALUES (3);
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
|
||||
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
|
||||
|
||||
INSERT INTO t2 VALUES (4);
|
||||
|
||||
--error ER_SUBQUERY_NO_1_ROW
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1;
|
||||
--error ER_SUBQUERY_NO_1_ROW
|
||||
SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1;
|
||||
|
||||
drop view v1;
|
||||
drop table t1,t2;
|
||||
|
||||
#
|
||||
# MDEV-7828 Assertion `key_read == 0' failed in TABLE::enable_keyread with SELECT SQ and WHERE SQ
|
||||
#
|
||||
CREATE TABLE t1 (f1 INT, KEY(f1)) ENGINE=MyISAM;
|
||||
INSERT t1 VALUES (4),(8);
|
||||
CREATE TABLE t2 (f2 INT, KEY(f2)) ENGINE=MyISAM;
|
||||
INSERT t2 VALUES (6),(9);
|
||||
SELECT (SELECT MAX(sq.f2) FROM t1) FROM (SELECT * FROM t2) AS sq WHERE f2 = 2;
|
||||
drop table t1, t2;
|
||||
|
||||
@@ -406,6 +406,8 @@ drop table t3, t4, t5;
|
||||
--echo # LP BUG#858038 The result of a query with NOT IN subquery depends on the state of the optimizer switch
|
||||
--echo #
|
||||
|
||||
set @optimizer_switch_save= @@optimizer_switch;
|
||||
|
||||
create table t1 (c1 char(2) not null, c2 char(2));
|
||||
create table t2 (c3 char(2), c4 char(2));
|
||||
|
||||
@@ -424,3 +426,100 @@ explain select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2);
|
||||
select * from t1 where c1 = 'a2' and (c1, c2) not in (select * from t2);
|
||||
|
||||
drop table t1, t2;
|
||||
|
||||
set optimizer_switch= @optimizer_switch_save;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-12673: cost-based choice between materialization and in-to-exists
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (
|
||||
pk1 int, a1 varchar(3), b1 varchar(3), PRIMARY KEY (pk1), KEY(a1), KEY(b1)
|
||||
) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1,'foo','bar'),(2,'bar','foo');
|
||||
|
||||
CREATE TABLE t2 (pk2 INT PRIMARY KEY, a2 VARCHAR(3), KEY(a2)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1,'abc'),(2,'xyz'),(3,'foo');
|
||||
|
||||
SELECT 'qux' IN ( SELECT a1 FROM t1 INNER JOIN t2 WHERE a2 = b1 AND pk2 = 3 );
|
||||
SELECT 'bar' IN ( SELECT a1 FROM t1 INNER JOIN t2 WHERE a2 = b1 AND pk2 = 3 );
|
||||
EXPLAIN
|
||||
SELECT 'bar' IN ( SELECT a1 FROM t1 INNER JOIN t2 WHERE a2 = b1 AND pk2 = 3 );
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
CREATE TABLE t1 (i1 INT) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1);
|
||||
|
||||
CREATE TABLE t2 (i2 int, c2 varchar(3), KEY(i2,c2)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1,'abc'),(2,'foo');
|
||||
|
||||
CREATE TABLE t3 (pk3 int PRIMARY KEY, c3 varchar(3)) ENGINE=MyISAM;
|
||||
INSERT INTO t3 VALUES (1,'foo'),(2,'bar');
|
||||
|
||||
SELECT * FROM t1 WHERE i1 NOT IN (
|
||||
SELECT i2 FROM t2 RIGHT JOIN t3 ON (c3 = c2) WHERE pk3 = i1
|
||||
);
|
||||
|
||||
EXPLAIN
|
||||
SELECT * FROM t1 WHERE i1 NOT IN (
|
||||
SELECT i2 FROM t2 RIGHT JOIN t3 ON (c3 = c2) WHERE pk3 = i1
|
||||
);
|
||||
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-7599: in-to-exists chosen after min/max optimization
|
||||
--echo #
|
||||
|
||||
set @optimizer_switch_save= @@optimizer_switch;
|
||||
|
||||
CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
|
||||
CREATE TABLE t2 (b INT, c INT) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (1,6),(2,4), (8,9);
|
||||
|
||||
let $q=
|
||||
SELECT * FROM t2 WHERE b != ALL (SELECT MIN(a) FROM t1, t2 WHERE t2.c = t2.b);
|
||||
|
||||
eval $q;
|
||||
eval EXPLAIN EXTENDED $q;
|
||||
set optimizer_switch= 'materialization=off';
|
||||
eval $q;
|
||||
eval EXPLAIN EXTENDED $q;
|
||||
set optimizer_switch= @optimizer_switch_save;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
CREATE TABLE t1 (f1 varchar(10)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('foo'),('bar');
|
||||
|
||||
CREATE TABLE t2 (f2 varchar(10), key(f2)) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES ('baz'),('qux');
|
||||
|
||||
CREATE TABLE t3 (f3 varchar(10)) ENGINE=MyISAM;
|
||||
INSERT INTO t3 VALUES ('abc'),('def');
|
||||
|
||||
SELECT * FROM t1
|
||||
WHERE f1 = ALL( SELECT MAX(t2a.f2)
|
||||
FROM t2 AS t2a INNER JOIN t2 t2b INNER JOIN t3
|
||||
ON (f3 = t2b.f2) );
|
||||
|
||||
DROP TABLE t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-12963: min/max optimization optimizing away all tables employed
|
||||
--echo # for uncorrelated IN subquery used in a disjunct of WHERE
|
||||
--echo #
|
||||
|
||||
create table t1 (a int, index idx(a)) engine=myisam;
|
||||
insert into t1 values (4),(7),(1),(3),(9);
|
||||
|
||||
select * from t1 where a in (select max(a) from t1 where a < 4) or a > 5;
|
||||
explain
|
||||
select * from t1 where a in (select max(a) from t1 where a < 4) or a > 5;
|
||||
|
||||
drop table t1;
|
||||
|
||||
|
||||
|
||||
@@ -97,3 +97,9 @@ set optimizer_switch= @tmp_subselect_nulls;
|
||||
|
||||
drop table x1;
|
||||
drop table x2;
|
||||
|
||||
#
|
||||
# MDEV-7339 Server crashes in Item_func_trig_cond::val_int
|
||||
#
|
||||
select (select 1, 2) in (select 3, 4);
|
||||
select (select NULL, NULL) in (select 3, 4);
|
||||
|
||||
@@ -2769,5 +2769,77 @@ WHERE ( SELECT z.country
|
||||
drop table t1, t2, t3;
|
||||
set optimizer_switch= @tmp_mdev6859;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-12675: subquery subject to semi-join optimizations
|
||||
--echo # in ON expression of INNER JOIN
|
||||
--echo #
|
||||
|
||||
set @tmp_mdev12675=@@optimizer_switch;
|
||||
set optimizer_switch=default;
|
||||
create table t1 (a int) engine=myisam;
|
||||
insert into t1 values (5),(3),(2),(7),(2),(5),(1);
|
||||
create table t2 (b int, index idx(b)) engine=myisam;
|
||||
insert into t2 values (2),(3),(2),(1),(3),(4);
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
insert into t2 select b+10 from t2;
|
||||
analyze table t1,t2;
|
||||
|
||||
explain
|
||||
select a from t1, t2 where b between 1 and 2 and a in (select b from t2);
|
||||
explain
|
||||
select a from t1 join t2 on b between 1 and 2 and a in (select b from t2);
|
||||
|
||||
drop table t1,t2;
|
||||
set optimizer_switch= @tmp_mdev12675;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-12817: subquery NOT subject to semi-join optimizations
|
||||
--echo # in ON expression of INNER JOIN
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (c1 int) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES (1),(2);
|
||||
|
||||
CREATE TABLE t2 (c2 int) ENGINE=MyISAM;
|
||||
INSERT INTO t2 VALUES (3),(4);
|
||||
|
||||
CREATE TABLE t3 (c3 int) ENGINE=MyISAM;
|
||||
INSERT INTO t3 VALUES (5),(6);
|
||||
|
||||
CREATE TABLE t4 (c4 int) ENGINE=MyISAM;
|
||||
INSERT INTO t4 VALUES (7),(8);
|
||||
|
||||
let $q1=
|
||||
SELECT c1
|
||||
FROM t1
|
||||
LEFT JOIN
|
||||
( t2 INNER JOIN t3 ON ( 1 IN ( SELECT c4 FROM t4 ) ) )
|
||||
ON (c1 = c3);
|
||||
|
||||
eval $q1;
|
||||
eval EXPLAIN EXTENDED $q1;
|
||||
|
||||
let $q2=
|
||||
SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN
|
||||
( ( SELECT * FROM t2 WHERE c2 IN ( SELECT c3 FROM t3 ) ) AS sq INNER JOIN t4 )
|
||||
ON (c1 = c2);
|
||||
|
||||
--echo # mdev-12820
|
||||
eval $q2;
|
||||
eval EXPLAIN EXTENDED $q2;
|
||||
|
||||
DROP TABLE t1,t2,t3,t4;
|
||||
|
||||
# The following command must be the last one the file
|
||||
set optimizer_switch=@subselect_sj_tmp;
|
||||
|
||||
@@ -263,3 +263,43 @@ DROP TABLE t1,t2,t3;
|
||||
set join_cache_level= @save_join_cache_level;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
--echo #
|
||||
--echo # mdev-7791: materialization of a semi-join subquery +
|
||||
--echo # RAND() in WHERE
|
||||
--echo # (materialized table is accessed last)
|
||||
--echo #
|
||||
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
set optimizer_switch='materialization=on';
|
||||
|
||||
create table t1(i int);
|
||||
insert into t1 values (1), (2), (3), (7), (9), (10);
|
||||
create table t2(i int);
|
||||
insert into t2 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
|
||||
|
||||
select * from t1 where (rand() < 0) and i in (select i from t2);
|
||||
explain extended
|
||||
select * from t1 where (rand() < 0) and i in (select i from t2);
|
||||
|
||||
drop table t1,t2;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
--echo #
|
||||
--echo # mdev-12855: materialization of a semi-join subquery + ORDER BY
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (f1 varchar(8), KEY(f1)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES ('qux'),('foo');
|
||||
CREATE TABLE t2 (f2 varchar(8)) ENGINE=InnoDB;
|
||||
INSERT INTO t2 VALUES ('bar'),('foo'),('qux');
|
||||
|
||||
let $q=
|
||||
SELECT f1 FROM t1
|
||||
WHERE f1 IN ( SELECT f2 FROM t2 WHERE f2 > 'bar' )
|
||||
HAVING f1 != 'foo'
|
||||
ORDER BY f1;
|
||||
|
||||
eval $q;
|
||||
eval explain $q;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
@@ -1944,4 +1944,211 @@ set optimizer_switch= @save_optimizer_switch;
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # mdev-12838: scan of materialized of semi-join subquery in join
|
||||
--echo #
|
||||
|
||||
set @save_optimizer_switch=@@optimizer_switch;
|
||||
|
||||
CREATE TABLE t1 (
|
||||
dispatch_group varchar(32),
|
||||
assignment_group varchar(32),
|
||||
sys_id char(32),
|
||||
PRIMARY KEY (sys_id),
|
||||
KEY idx1 (dispatch_group),
|
||||
KEY idx2 (assignment_group)
|
||||
) ENGINE=MyISAM;
|
||||
|
||||
CREATE TABLE t2 (
|
||||
ugroup varchar(32),
|
||||
user varchar(32),
|
||||
sys_id char(32),
|
||||
PRIMARY KEY (sys_id),
|
||||
KEY idx3 (ugroup),
|
||||
KEY idx4 (user)
|
||||
) ENGINE=MyISAM;
|
||||
|
||||
CREATE TABLE t3 (
|
||||
type mediumtext,
|
||||
sys_id char(32),
|
||||
PRIMARY KEY (sys_id)
|
||||
) ENGINE=MyISAM;
|
||||
|
||||
--disable_query_log
|
||||
|
||||
INSERT INTO t1 VALUES
|
||||
('e5d9f63237232000158bbfc8bcbe5dbf','f304ae0037332000158bbfc8bcbe5d4f',
|
||||
'5398c0e037003000158bbfc8bcbe5dbb'),
|
||||
('69d9f63237232000158bbfc8bcbe5dcb','7172ea0037332000158bbfc8bcbe5db6',
|
||||
'5c188ca037003000158bbfc8bcbe5dbc'),
|
||||
('577ed708d773020058c92cf65e61037a','699708d4d773020058c92cf65e61037c',
|
||||
'623a8cd4d773020058c92cf65e6103ea'),
|
||||
('96fb652637232000158bbfc8bcbe5db4','df50316637232000158bbfc8bcbe5d23',
|
||||
'6835bd6637232000158bbfc8bcbe5d21'),
|
||||
('e1d9f63237232000158bbfc8bcbe5db8','96346e0037332000158bbfc8bcbe5daa',
|
||||
'697880e037003000158bbfc8bcbe5dcd'),
|
||||
('25d9f63237232000158bbfc8bcbe5dbe','f304ae0037332000158bbfc8bcbe5d4f',
|
||||
'6a9804e037003000158bbfc8bcbe5d09'),
|
||||
('96fb652637232000158bbfc8bcbe5db4','e08fad2637232000158bbfc8bcbe5d39',
|
||||
'6d25f96637232000158bbfc8bcbe5d79'),
|
||||
('e9d9f63237232000158bbfc8bcbe5dc6','7172ea0037332000158bbfc8bcbe5db6',
|
||||
'702880e037003000158bbfc8bcbe5d94'),
|
||||
('a5d9f63237232000158bbfc8bcbe5dca','f304ae0037332000158bbfc8bcbe5d4f',
|
||||
'7188c0e037003000158bbfc8bcbe5d75'),
|
||||
('65d9f63237232000158bbfc8bcbe5dc4','f304ae0037332000158bbfc8bcbe5d4f',
|
||||
'778880e037003000158bbfc8bcbe5d9e'),
|
||||
('a1d9f63237232000158bbfc8bcbe5dc3','7172ea0037332000158bbfc8bcbe5db6',
|
||||
'7d0840e037003000158bbfc8bcbe5dde'),
|
||||
('21d9f63237232000158bbfc8bcbe5db7','96346e0037332000158bbfc8bcbe5daa',
|
||||
'7f6880e037003000158bbfc8bcbe5da7'),
|
||||
('96fb652637232000158bbfc8bcbe5db4','ec70316637232000158bbfc8bcbe5d60',
|
||||
'8025f96637232000158bbfc8bcbe5dd0'),
|
||||
('3dd9f63237232000158bbfc8bcbe5dcc','7172ea0037332000158bbfc8bcbe5db6',
|
||||
'823880e037003000158bbfc8bcbe5ded'),
|
||||
('96fb652637232000158bbfc8bcbe5db4','7b10fd2637232000158bbfc8bcbe5d30',
|
||||
'9a353d6637232000158bbfc8bcbe5dee'),
|
||||
('75d9f63237232000158bbfc8bcbe5dd0','ebb4620037332000158bbfc8bcbe5d89',
|
||||
'a558c0e037003000158bbfc8bcbe5d36'),
|
||||
('6dd9f63237232000158bbfc8bcbe5db5','96346e0037332000158bbfc8bcbe5daa',
|
||||
'bc78cca037003000158bbfc8bcbe5d74'),
|
||||
('add9f63237232000158bbfc8bcbe5dc7','7172ea0037332000158bbfc8bcbe5db6',
|
||||
'c53804a037003000158bbfc8bcbe5db8'),
|
||||
('fdd9f63237232000158bbfc8bcbe5dcd','7864ae0037332000158bbfc8bcbe5db8',
|
||||
'cfe740e037003000158bbfc8bcbe5de8'),
|
||||
('96fb652637232000158bbfc8bcbe5db4','3120fd2637232000158bbfc8bcbe5d42',
|
||||
'e2257d6637232000158bbfc8bcbe5ded'),
|
||||
('3c3725e237232000158bbfc8bcbe5da1','96346e0037332000158bbfc8bcbe5daa',
|
||||
'ee78c0e037003000158bbfc8bcbe5db5'),
|
||||
('a9d9f63237232000158bbfc8bcbe5dc0','7172ea0037332000158bbfc8bcbe5db6',
|
||||
'f00888a037003000158bbfc8bcbe5dd3'),
|
||||
('29d9f63237232000158bbfc8bcbe5db9','7172ea0037332000158bbfc8bcbe5db6',
|
||||
'fa0880e037003000158bbfc8bcbe5d70'),
|
||||
('b1d9f63237232000158bbfc8bcbe5dcf','ebb4620037332000158bbfc8bcbe5d89',
|
||||
'fa48c0e037003000158bbfc8bcbe5d28');
|
||||
|
||||
INSERT INTO t2 VALUES
|
||||
('17801ac21b13200050fdfbcd2c0713e8','8e826bf03710200044e0bfc8bcbe5d86',
|
||||
'14c19a061b13200050fdfbcd2c07134b'),
|
||||
('577ed708d773020058c92cf65e61037a','931644d4d773020058c92cf65e61034c',
|
||||
'339888d4d773020058c92cf65e6103aa'),
|
||||
('df50316637232000158bbfc8bcbe5d23','92826bf03710200044e0bfc8bcbe5da9',
|
||||
'3682f56637232000158bbfc8bcbe5d44'),
|
||||
('b4f342b237232000158bbfc8bcbe5def','86826bf03710200044e0bfc8bcbe5d70',
|
||||
'38e4c2b237232000158bbfc8bcbe5dea'),
|
||||
('7b10fd2637232000158bbfc8bcbe5d30','8a826bf03710200044e0bfc8bcbe5d72',
|
||||
'4442b56637232000158bbfc8bcbe5d43'),
|
||||
('3120fd2637232000158bbfc8bcbe5d42','82826bf03710200044e0bfc8bcbe5d89',
|
||||
'49d2396637232000158bbfc8bcbe5d12'),
|
||||
('96fb652637232000158bbfc8bcbe5db4','86826bf03710200044e0bfc8bcbe5d79',
|
||||
'4e3ca52637232000158bbfc8bcbe5d3e'),
|
||||
('17801ac21b13200050fdfbcd2c0713e8','824fd523bf4320007a6d257b3f073963',
|
||||
'58c19a061b13200050fdfbcd2c07134e'),
|
||||
('699708d4d773020058c92cf65e61037c','901784d4d773020058c92cf65e6103da',
|
||||
'5bc708d4d773020058c92cf65e6103d5'),
|
||||
('75d9f63237232000158bbfc8bcbe5dd0','86826bf03710200044e0bfc8bcbe5d79',
|
||||
'6b52cb7237232000158bbfc8bcbe5ded'),
|
||||
('f253da061b13200050fdfbcd2c0713ab','8e826bf03710200044e0bfc8bcbe5d86',
|
||||
'81045e061b13200050fdfbcd2c071373'),
|
||||
('7b10fd2637232000158bbfc8bcbe5d30','8e826bf03710200044e0bfc8bcbe5d74',
|
||||
'8c42b56637232000158bbfc8bcbe5d3f'),
|
||||
('e5d9f63237232000158bbfc8bcbe5dbf','7a826bf03710200044e0bfc8bcbe5df5',
|
||||
'a7acfe3237232000158bbfc8bcbe5d78'),
|
||||
('8a5055c9c61122780043563ef53438e3','9ee1b13dc6112271007f9d0efdb69cd0',
|
||||
'a9aff553c6112276015a8006174bee21'),
|
||||
('8a4dde73c6112278017a6a4baf547aa7','9ee1b13dc6112271007f9d0efdb69cd0',
|
||||
'a9b2f526c61122760003ae07349d294f'),
|
||||
('aaccc971c0a8001500fe1ff4302de101','9ee1b13dc6112271007f9d0efdb69cd0',
|
||||
'aacceed3c0a80015009069bba51c4e21'),
|
||||
('65d9f63237232000158bbfc8bcbe5dc4','8d56406a0a0a0a6b004070b354aada28',
|
||||
'ac1bfa3237232000158bbfc8bcbe5dc3'),
|
||||
('b85d44954a3623120004689b2d5dd60a','97000fcc0a0a0a6e0104ca999f619e5b',
|
||||
'b77bc032cbb00200d71cb9c0c24c9c45'),
|
||||
('220f8e71c61122840197e57c33464f70','8d56406a0a0a0a6b004070b354aada28',
|
||||
'b9b74f080a0a0b343ba75b95bdb27056'),
|
||||
('e08fad2637232000158bbfc8bcbe5d39','82826bf03710200044e0bfc8bcbe5d80',
|
||||
'be02756637232000158bbfc8bcbe5d8b'),
|
||||
('ebb4620037332000158bbfc8bcbe5d89','7682abf03710200044e0bfc8bcbe5d25',
|
||||
'c0122f4437732000158bbfc8bcbe5d7d'),
|
||||
('96fb652637232000158bbfc8bcbe5db4','7a82abf03710200044e0bfc8bcbe5d27',
|
||||
'c23ca52637232000158bbfc8bcbe5d3b'),
|
||||
('22122b37c611228400f9ff91c857581d','9ee1b13dc6112271007f9d0efdb69cd0',
|
||||
'd23bbf5dac14641866947512bde59dc5'),
|
||||
('db53a9290a0a0a650091abebccf833c6','9ee1b13dc6112271007f9d0efdb69cd0',
|
||||
'db54a0f60a0a0a65002c54dcb72b4f41'),
|
||||
('e08fad2637232000158bbfc8bcbe5d39','8e826bf03710200044e0bfc8bcbe5d86',
|
||||
'f602756637232000158bbfc8bcbe5d88'),
|
||||
('699708d4d773020058c92cf65e61037c','8d59d601d7b3020058c92cf65e6103c2',
|
||||
'f718a241d7b3020058c92cf65e610332'),
|
||||
('df50316637232000158bbfc8bcbe5d23','9e826bf03710200044e0bfc8bcbe5da6',
|
||||
'fe82f56637232000158bbfc8bcbe5d4e'),
|
||||
('f972d6061b13200050fdfbcd2c0713e5','780395f0df031100a9e78b6c3df2631f',
|
||||
'ff4395f0df031100a9e78b6c3df2637e');
|
||||
|
||||
INSERT INTO t3 VALUES
|
||||
('87245e061b13200050fdfbcd2c0713cc','7172ea0037332000158bbfc8bcbe5db6'),
|
||||
('74af88c6c611227d0066386e74dc853d','74ad1ff3c611227d01d25feac2af603f'),
|
||||
('59e22fb137032000158bbfc8bcbe5d52','75d9f63237232000158bbfc8bcbe5dd0'),
|
||||
('98906fb137032000158bbfc8bcbe5d65','781da52637232000158bbfc8bcbe5db8'),
|
||||
('87245e061b13200050fdfbcd2c0713cc','7864ae0037332000158bbfc8bcbe5db8'),
|
||||
('87245e061b13200050fdfbcd2c0713cc','7b10fd2637232000158bbfc8bcbe5d30'),
|
||||
('59e22fb137032000158bbfc8bcbe5d52','81a880e037003000158bbfc8bcbe5df8'),
|
||||
('74af88c6c611227d0066386e74dc853d','8a4cb6d4c61122780043b1642efcd52b'),
|
||||
('1cb8ab9bff500200158bffffffffff62','8a4dde73c6112278017a6a4baf547aa7'),
|
||||
('1cb8ab9bff500200158bffffffffff62','8a5055c9c61122780043563ef53438e3'),
|
||||
('87245e061b13200050fdfbcd2c0713cc','96346e0037332000158bbfc8bcbe5daa'),
|
||||
('59e22fb137032000158bbfc8bcbe5d52','96fb652637232000158bbfc8bcbe5db4'),
|
||||
('59e22fb137032000158bbfc8bcbe5d52','a1d9f63237232000158bbfc8bcbe5dc3'),
|
||||
('59e22fb137032000158bbfc8bcbe5d52','a5d9f63237232000158bbfc8bcbe5dca'),
|
||||
('1cb8ab9bff500200158bffffffffff62','a715cd759f2002002920bde8132e7018'),
|
||||
('59e22fb137032000158bbfc8bcbe5d52','a9d9f63237232000158bbfc8bcbe5dc0'),
|
||||
('74af88c6c611227d0066386e74dc853d','aacb62e2c0a80015007f67f752c2b12c'),
|
||||
('74af88c6c611227d0066386e74dc853d','aaccc971c0a8001500fe1ff4302de101'),
|
||||
('59e22fb137032000158bbfc8bcbe5d52','add9f63237232000158bbfc8bcbe5dbb'),
|
||||
('59e22fb137032000158bbfc8bcbe5d52','add9f63237232000158bbfc8bcbe5dc7'),
|
||||
('59e22fb137032000158bbfc8bcbe5d52','b1d9f63237232000158bbfc8bcbe5dcf'),
|
||||
('1cb8ab9bff500200158bffffffffff62','b85d44954a3623120004689b2d5dd60a'),
|
||||
('1cb8ab9bff500200158bffffffffff62','b97e89b94a36231201676b73322a0311'),
|
||||
('1cb8ab9bff500200158bffffffffff62','cfcbad03d711110050f5edcb9e61038f'),
|
||||
('1cb8ab9bff500200158bffffffffff62','d625dccec0a8016700a222a0f7900d06'),
|
||||
('1cb8ab9bff500200158bffffffffff62','db53580b0a0a0a6501aa37c294a2ba6b'),
|
||||
('1cb8ab9bff500200158bffffffffff62','db53a9290a0a0a650091abebccf833c6'),
|
||||
('1cb8ab9bff500200158bffffffffff62','dc0db135c332010016194ffe5bba8f23'),
|
||||
('87245e061b13200050fdfbcd2c0713cc','df50316637232000158bbfc8bcbe5d23'),
|
||||
('87245e061b13200050fdfbcd2c0713cc','e08fad2637232000158bbfc8bcbe5d39'),
|
||||
('59e22fb137032000158bbfc8bcbe5d52','e1d9f63237232000158bbfc8bcbe5db8'),
|
||||
('59e22fb137032000158bbfc8bcbe5d52','e5d9f63237232000158bbfc8bcbe5db4'),
|
||||
('59e22fb137032000158bbfc8bcbe5d52','e5d9f63237232000158bbfc8bcbe5dbf'),
|
||||
('59e22fb137032000158bbfc8bcbe5d52','e9d9f63237232000158bbfc8bcbe5dba'),
|
||||
('59e22fb137032000158bbfc8bcbe5d52','e9d9f63237232000158bbfc8bcbe5dc6'),
|
||||
('87245e061b13200050fdfbcd2c0713cc','ebb4620037332000158bbfc8bcbe5d89'),
|
||||
('87245e061b13200050fdfbcd2c0713cc','ec70316637232000158bbfc8bcbe5d60'),
|
||||
('87245e061b13200050fdfbcd2c0713cc','f253da061b13200050fdfbcd2c0713ab'),
|
||||
('87245e061b13200050fdfbcd2c0713cc','f304ae0037332000158bbfc8bcbe5d4f'),
|
||||
('98906fb137032000158bbfc8bcbe5d65','f972d6061b13200050fdfbcd2c0713e5'),
|
||||
('59e22fb137032000158bbfc8bcbe5d52','fdd9f63237232000158bbfc8bcbe5dcd');
|
||||
|
||||
--enable_query_log
|
||||
|
||||
let $q=
|
||||
SELECT t1.assignment_group
|
||||
FROM t1, t3
|
||||
WHERE t1.assignment_group = t3.sys_id AND
|
||||
t1.dispatch_group IN
|
||||
(SELECT t2.ugroup
|
||||
FROM t2, t3 t3_i
|
||||
WHERE t2.ugroup = t3_i.sys_id AND
|
||||
t3_i.type LIKE '59e22fb137032000158bbfc8bcbe5d52' AND
|
||||
t2.user = '86826bf03710200044e0bfc8bcbe5d79');
|
||||
|
||||
set optimizer_switch='materialization=off';
|
||||
eval explain $q;
|
||||
eval $q;
|
||||
|
||||
set optimizer_switch='materialization=on';
|
||||
eval explain $q;
|
||||
eval $q;
|
||||
|
||||
DROP TABLE t1,t2,t3;
|
||||
set optimizer_switch=@save_optimizer_switch;
|
||||
|
||||
--echo # End of 5.5 tests
|
||||
|
||||
@@ -1370,3 +1370,18 @@ order by d;
|
||||
drop table t1;
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
||||
#
|
||||
# Bug #24595639: INCORRECT BEHAVIOR IN QUERY WITH UNION AND GROUP BY
|
||||
#
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (1,1),(2,2),(3,3);
|
||||
create table t2 (c varchar(30), d varchar(30));
|
||||
insert into t1 values ('1','1'),('2','2'),('4','4');
|
||||
create table t3 (e int, f int);
|
||||
insert into t3 values (1,1),(2,2),(31,31),(32,32);
|
||||
select e,f, (e , f) in (select e,b from t1 union select c,d from t2) as sub from t3;
|
||||
select avg(f), (e , f) in (select e,b from t1 union select c,d from t2) as sub from t3 group by sub;
|
||||
drop table t1,t2,t3;
|
||||
|
||||
--echo End of 5.5 tests
|
||||
|
||||
@@ -5565,6 +5565,22 @@ select *
|
||||
drop view v1;
|
||||
drop table t1,t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-11240: Server crashes in check_view_single_update or
|
||||
--echo # Assertion `derived->table' failed in mysql_derived_merge_for_insert
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t3 (a INT);
|
||||
CREATE ALGORITHM = MERGE VIEW v1 AS SELECT t2.a FROM t3 AS t1, t3 AS t2;
|
||||
CREATE ALGORITHM = MERGE VIEW v2 AS SELECT * FROM v1;
|
||||
PREPARE stmt FROM 'REPLACE INTO v2 SELECT a FROM t3';
|
||||
--error ER_VIEW_NO_INSERT_FIELD_LIST
|
||||
EXECUTE stmt;
|
||||
--error ER_VIEW_NO_INSERT_FIELD_LIST
|
||||
EXECUTE stmt;
|
||||
drop view v1,v2;
|
||||
drop table t3;
|
||||
|
||||
--echo # -----------------------------------------------------------------
|
||||
--echo # -- End of 5.5 tests.
|
||||
--echo # -----------------------------------------------------------------
|
||||
|
||||
@@ -143,7 +143,7 @@ static int no_close(void *cookie __attribute__((unused)))
|
||||
/*
|
||||
A hack around a race condition in the implementation of freopen.
|
||||
|
||||
The race condition steams from the fact that the current fd of
|
||||
The race condition stems from the fact that the current fd of
|
||||
the stream is closed before its number is used to duplicate the
|
||||
new file descriptor. This defeats the desired atomicity of the
|
||||
close and duplicate of dup2().
|
||||
|
||||
@@ -129,6 +129,31 @@ ulonglong my_timer_cycles_il_x86_64();
|
||||
clock_gettime(CLOCK_SGI_CYCLE) for Irix platforms,
|
||||
or on read_real_time for aix platforms. There is
|
||||
nothing for Alpha platforms, they would be tricky.
|
||||
|
||||
On the platforms that do not have a CYCLE timer,
|
||||
"wait" events are initialized to use NANOSECOND instead of CYCLE
|
||||
during performance_schema initialization (at the server startup).
|
||||
|
||||
Linux performance monitor (see "man perf_event_open") can
|
||||
provide cycle counter on the platforms that do not have
|
||||
other kinds of cycle counters. But we don't use it so far.
|
||||
|
||||
ARM notes
|
||||
---------
|
||||
During tests on ARMv7 Debian, perf_even_open() based cycle counter provided
|
||||
too low frequency with too high overhead:
|
||||
MariaDB [performance_schema]> SELECT * FROM performance_timers;
|
||||
+-------------+-----------------+------------------+----------------+
|
||||
| TIMER_NAME | TIMER_FREQUENCY | TIMER_RESOLUTION | TIMER_OVERHEAD |
|
||||
+-------------+-----------------+------------------+----------------+
|
||||
| CYCLE | 689368159 | 1 | 970 |
|
||||
| NANOSECOND | 1000000000 | 1 | 308 |
|
||||
| MICROSECOND | 1000000 | 1 | 417 |
|
||||
| MILLISECOND | 1000 | 1000 | 407 |
|
||||
| TICK | 127 | 1 | 612 |
|
||||
+-------------+-----------------+------------------+----------------+
|
||||
Therefore, it was decided not to use perf_even_open() on ARM
|
||||
(i.e. go without CYCLE and have "wait" events use NANOSECOND by default).
|
||||
*/
|
||||
|
||||
ulonglong my_timer_cycles(void)
|
||||
|
||||
@@ -197,7 +197,7 @@ int my_realpath(char *to, const char *filename, myf MyFlags)
|
||||
|
||||
const char *my_open_parent_dir_nosymlinks(const char *pathname, int *pdfd)
|
||||
{
|
||||
char buf[PATH_MAX+1];
|
||||
char buf[FN_REFLEN + 1];
|
||||
char *s= buf, *e= buf+1, *end= strnmov(buf, pathname, sizeof(buf));
|
||||
int fd, dfd= -1;
|
||||
|
||||
|
||||
@@ -107,12 +107,21 @@ const char *my_open_parent_dir_nosymlinks(const char *pathname, int *pdfd);
|
||||
res= AT; \
|
||||
if (dfd >= 0) close(dfd); \
|
||||
return res;
|
||||
#elif defined(HAVE_REALPATH)
|
||||
#elif defined(HAVE_REALPATH) && defined(PATH_MAX)
|
||||
#define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \
|
||||
char buf[PATH_MAX+1]; \
|
||||
if (realpath(pathname, buf) == NULL) return -1; \
|
||||
if (strcmp(pathname, buf)) { errno= ENOTDIR; return -1; } \
|
||||
return NOAT;
|
||||
#elif defined(HAVE_REALPATH)
|
||||
#define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \
|
||||
char *buf= realpath(pathname, NULL); \
|
||||
int res; \
|
||||
if (buf == NULL) return -1; \
|
||||
if (strcmp(pathname, buf)) { errno= ENOTDIR; res= -1; } \
|
||||
else res= NOAT; \
|
||||
free(buf); \
|
||||
return res;
|
||||
#else
|
||||
#define NOSYMLINK_FUNCTION_BODY(AT,NOAT) \
|
||||
return NOAT;
|
||||
|
||||
@@ -744,7 +744,7 @@ void my_safe_print_str(const char *val, int len)
|
||||
|
||||
size_t my_write_stderr(const void *buf, size_t count)
|
||||
{
|
||||
return (size_t) write(STDERR_FILENO, buf, count);
|
||||
return (size_t) write(fileno(stderr), buf, count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -552,7 +552,7 @@ int ReplSemiSyncMaster::reportReplyBinlog(uint32 server_id,
|
||||
|
||||
if (need_copy_send_pos)
|
||||
{
|
||||
strcpy(reply_file_name_, log_file_name);
|
||||
strmake_buf(reply_file_name_, log_file_name);
|
||||
reply_file_pos_ = log_file_pos;
|
||||
reply_file_name_inited_ = true;
|
||||
|
||||
@@ -659,7 +659,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
|
||||
if (cmp <= 0)
|
||||
{
|
||||
/* This thd has a lower position, let's update the minimum info. */
|
||||
strcpy(wait_file_name_, trx_wait_binlog_name);
|
||||
strmake_buf(wait_file_name_, trx_wait_binlog_name);
|
||||
wait_file_pos_ = trx_wait_binlog_pos;
|
||||
|
||||
rpl_semi_sync_master_wait_pos_backtraverse++;
|
||||
@@ -670,7 +670,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(wait_file_name_, trx_wait_binlog_name);
|
||||
strmake_buf(wait_file_name_, trx_wait_binlog_name);
|
||||
wait_file_pos_ = trx_wait_binlog_pos;
|
||||
wait_file_name_inited_ = true;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2006, 2017, Oracle and/or its affiliates.
|
||||
# Copyright (c) 2011, 2017, MariaDB Corporation
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -95,6 +96,13 @@ IF(CMAKE_GENERATOR MATCHES "Makefiles")
|
||||
ENDFOREACH()
|
||||
ENDIF()
|
||||
|
||||
|
||||
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
SET (PERL_PATH "/usr/local/bin/perl")
|
||||
ELSE()
|
||||
SET (PERL_PATH "/usr/bin/perl")
|
||||
ENDIF()
|
||||
|
||||
IF(UNIX)
|
||||
# FIND_PROC and CHECK_PID are used by mysqld_safe
|
||||
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
@@ -407,4 +415,3 @@ IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_FLAGS MATCHES "-static")
|
||||
COMPONENT Development)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
|
||||
8
scripts/dheadgen.pl
Executable file → Normal file
8
scripts/dheadgen.pl
Executable file → Normal file
@@ -1,10 +1,4 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
#
|
||||
# Copyright (c) 2008, 2009 Sun Microsystems, Inc.
|
||||
# Use is subject to license terms.
|
||||
#
|
||||
|
||||
# Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/perl
|
||||
#!@PERL_PATH@
|
||||
# -*- cperl -*-
|
||||
#
|
||||
# Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
# Copyright (c) 2000-2002, 2006, 2007 MySQL AB, 2009 Sun Microsystems, Inc.
|
||||
# Use is subject to license terms.
|
||||
#!@PERL_PATH@
|
||||
# Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
# Copyright (c) 2000, 2004, 2006 MySQL AB, 2009 Sun Microsystems, Inc.
|
||||
# Use is subject to license terms.
|
||||
#!@PERL_PATH@
|
||||
# Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/perl
|
||||
#!@PERL_PATH@
|
||||
|
||||
# Copyright (c) 2001 MySQL AB, 2009 Sun Microsystems, Inc.
|
||||
# Use is subject to license terms.
|
||||
# Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/perl
|
||||
#!@PERL_PATH@
|
||||
# -*- cperl -*-
|
||||
#
|
||||
# Copyright (c) 2007, 2013, Oracle and/or its affiliates.
|
||||
# Copyright (c) 2007, 2017, Oracle and/or its affiliates.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/perl
|
||||
#!@PERL_PATH@
|
||||
# -*- cperl -*-
|
||||
#
|
||||
# Copyright (c) 2007, 2012, Oracle and/or its affiliates.
|
||||
# Copyright (c) 2007, 2017, Oracle and/or its affiliates.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -388,6 +388,3 @@ Thanks for using MySQL!
|
||||
|
||||
|
||||
HERE
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#!/usr/bin/perl
|
||||
#!@PERL_PATH@
|
||||
## Emacs, this is -*- perl -*- mode? :-)
|
||||
|
||||
# Copyright (c) 2000, 2007 MySQL AB, 2009 Sun Microsystems, Inc.
|
||||
# Use is subject to license terms.
|
||||
# Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
# Copyright (c) 2000-2002, 2004, 2006 MySQL AB, 2009 Sun Microsystems, Inc.
|
||||
# Use is subject to license terms.
|
||||
#!@PERL_PATH@
|
||||
# Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/perl
|
||||
#!@PERL_PATH@
|
||||
|
||||
# Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
@@ -477,15 +477,22 @@ MySQLaccess::Report::Print_Header();
|
||||
# *****************************
|
||||
# Read configuration-file
|
||||
MySQLaccess::Debug::Print(1, "Reading configuration file...");
|
||||
if (-f "./$script_conf") {
|
||||
require "./$script_conf";
|
||||
}
|
||||
elsif (-f "@sysconfdir@/$script_conf") {
|
||||
if (-f "@sysconfdir@/$script_conf") {
|
||||
print "Configuration file '$script_conf' is found in '@sysconfdir@/'\n";
|
||||
require "@sysconfdir@/$script_conf";
|
||||
}
|
||||
elsif (-f "/etc/$script_conf") {
|
||||
print "Configuration file '$script_conf' is found in '/etc/'\n";
|
||||
require "/etc/$script_conf";
|
||||
}
|
||||
elsif (-f "./$script_conf") {
|
||||
print "\nERROR! Configuration file '$script_conf' is found in the current ";
|
||||
print "directory.\nThe permissible locations for this file are either ";
|
||||
print "@sysconfdir@/ or /etc/\n";
|
||||
print "Please move it to one of these locations and retry.\n\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
# ****************************
|
||||
# Read in all parameters
|
||||
|
||||
@@ -1,23 +1,7 @@
|
||||
#!/usr/bin/perl
|
||||
# Copyright (c) 2000, 2010, Oracle and/or its affiliates.
|
||||
# Copyright (c) 2000-2011 Monty Program Ab, Jani Tolonen
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; version 2
|
||||
# of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
|
||||
# MA 02110-1301, USA
|
||||
#!@PERL_PATH@
|
||||
|
||||
# Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2000, 2017, Oracle and/or its affiliates.
|
||||
# Copyright (c) 2010, 2017, MariaDB Corporation
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/perl
|
||||
#!@PERL_PATH@
|
||||
|
||||
# Copyright (c) 2000-2002, 2005-2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc.
|
||||
# Use is subject to license terms.
|
||||
# Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/perl
|
||||
#!@PERL_PATH@
|
||||
|
||||
# Copyright (c) 2000, 2010, Oracle and/or its affiliates
|
||||
# Copyright (c) 2000, 2017, Oracle and/or its affiliates.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
|
||||
@@ -640,7 +640,7 @@ int ha_partition::create(const char *name, TABLE *table_arg,
|
||||
int ha_partition::drop_partitions(const char *path)
|
||||
{
|
||||
List_iterator<partition_element> part_it(m_part_info->partitions);
|
||||
char part_name_buff[FN_REFLEN];
|
||||
char part_name_buff[FN_REFLEN + 1];
|
||||
uint num_parts= m_part_info->partitions.elements;
|
||||
uint num_subparts= m_part_info->num_subparts;
|
||||
uint i= 0;
|
||||
@@ -673,9 +673,11 @@ int ha_partition::drop_partitions(const char *path)
|
||||
{
|
||||
partition_element *sub_elem= sub_it++;
|
||||
part= i * num_subparts + j;
|
||||
create_subpartition_name(part_name_buff, path,
|
||||
part_elem->partition_name,
|
||||
sub_elem->partition_name, name_variant);
|
||||
if ((ret_error= create_subpartition_name(part_name_buff,
|
||||
sizeof(part_name_buff), path,
|
||||
part_elem->partition_name,
|
||||
sub_elem->partition_name, name_variant)))
|
||||
error= ret_error;
|
||||
file= m_file[part];
|
||||
DBUG_PRINT("info", ("Drop subpartition %s", part_name_buff));
|
||||
if ((ret_error= file->ha_delete_table(part_name_buff)))
|
||||
@@ -686,15 +688,19 @@ int ha_partition::drop_partitions(const char *path)
|
||||
}
|
||||
else
|
||||
{
|
||||
create_partition_name(part_name_buff, path,
|
||||
part_elem->partition_name, name_variant,
|
||||
TRUE);
|
||||
file= m_file[i];
|
||||
DBUG_PRINT("info", ("Drop partition %s", part_name_buff));
|
||||
if ((ret_error= file->ha_delete_table(part_name_buff)))
|
||||
if ((ret_error= create_partition_name(part_name_buff,
|
||||
sizeof(part_name_buff), path,
|
||||
part_elem->partition_name, name_variant, TRUE)))
|
||||
error= ret_error;
|
||||
if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos))
|
||||
error= 1;
|
||||
else
|
||||
{
|
||||
file= m_file[i];
|
||||
DBUG_PRINT("info", ("Drop partition %s", part_name_buff));
|
||||
if ((ret_error= file->ha_delete_table(part_name_buff)))
|
||||
error= ret_error;
|
||||
if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos))
|
||||
error= 1;
|
||||
}
|
||||
}
|
||||
if (part_elem->part_state == PART_IS_CHANGED)
|
||||
part_elem->part_state= PART_NORMAL;
|
||||
@@ -730,8 +736,8 @@ int ha_partition::rename_partitions(const char *path)
|
||||
{
|
||||
List_iterator<partition_element> part_it(m_part_info->partitions);
|
||||
List_iterator<partition_element> temp_it(m_part_info->temp_partitions);
|
||||
char part_name_buff[FN_REFLEN];
|
||||
char norm_name_buff[FN_REFLEN];
|
||||
char part_name_buff[FN_REFLEN + 1];
|
||||
char norm_name_buff[FN_REFLEN + 1];
|
||||
uint num_parts= m_part_info->partitions.elements;
|
||||
uint part_count= 0;
|
||||
uint num_subparts= m_part_info->num_subparts;
|
||||
@@ -773,10 +779,11 @@ int ha_partition::rename_partitions(const char *path)
|
||||
{
|
||||
sub_elem= sub_it++;
|
||||
file= m_reorged_file[part_count++];
|
||||
create_subpartition_name(norm_name_buff, path,
|
||||
part_elem->partition_name,
|
||||
sub_elem->partition_name,
|
||||
NORMAL_PART_NAME);
|
||||
if ((ret_error= create_subpartition_name(norm_name_buff,
|
||||
sizeof(norm_name_buff), path,
|
||||
part_elem->partition_name,
|
||||
sub_elem->partition_name, NORMAL_PART_NAME)))
|
||||
error= ret_error;
|
||||
DBUG_PRINT("info", ("Delete subpartition %s", norm_name_buff));
|
||||
if ((ret_error= file->ha_delete_table(norm_name_buff)))
|
||||
error= ret_error;
|
||||
@@ -789,16 +796,20 @@ int ha_partition::rename_partitions(const char *path)
|
||||
else
|
||||
{
|
||||
file= m_reorged_file[part_count++];
|
||||
create_partition_name(norm_name_buff, path,
|
||||
part_elem->partition_name, NORMAL_PART_NAME,
|
||||
TRUE);
|
||||
DBUG_PRINT("info", ("Delete partition %s", norm_name_buff));
|
||||
if ((ret_error= file->ha_delete_table(norm_name_buff)))
|
||||
if ((ret_error= create_partition_name(norm_name_buff,
|
||||
sizeof(norm_name_buff), path,
|
||||
part_elem->partition_name, NORMAL_PART_NAME, TRUE)))
|
||||
error= ret_error;
|
||||
else if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos))
|
||||
error= 1;
|
||||
else
|
||||
part_elem->log_entry= NULL; /* Indicate success */
|
||||
{
|
||||
DBUG_PRINT("info", ("Delete partition %s", norm_name_buff));
|
||||
if ((ret_error= file->ha_delete_table(norm_name_buff)))
|
||||
error= ret_error;
|
||||
else if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos))
|
||||
error= 1;
|
||||
else
|
||||
part_elem->log_entry= NULL; /* Indicate success */
|
||||
}
|
||||
}
|
||||
} while (++i < temp_partitions);
|
||||
(void) sync_ddl_log();
|
||||
@@ -841,10 +852,11 @@ int ha_partition::rename_partitions(const char *path)
|
||||
{
|
||||
sub_elem= sub_it++;
|
||||
part= i * num_subparts + j;
|
||||
create_subpartition_name(norm_name_buff, path,
|
||||
part_elem->partition_name,
|
||||
sub_elem->partition_name,
|
||||
NORMAL_PART_NAME);
|
||||
if ((ret_error= create_subpartition_name(norm_name_buff,
|
||||
sizeof(norm_name_buff), path,
|
||||
part_elem->partition_name,
|
||||
sub_elem->partition_name, NORMAL_PART_NAME)))
|
||||
error= ret_error;
|
||||
if (part_elem->part_state == PART_IS_CHANGED)
|
||||
{
|
||||
file= m_reorged_file[part_count++];
|
||||
@@ -856,10 +868,11 @@ int ha_partition::rename_partitions(const char *path)
|
||||
(void) sync_ddl_log();
|
||||
}
|
||||
file= m_new_file[part];
|
||||
create_subpartition_name(part_name_buff, path,
|
||||
part_elem->partition_name,
|
||||
sub_elem->partition_name,
|
||||
TEMP_PART_NAME);
|
||||
if ((ret_error= create_subpartition_name(part_name_buff,
|
||||
sizeof(part_name_buff), path,
|
||||
part_elem->partition_name,
|
||||
sub_elem->partition_name, TEMP_PART_NAME)))
|
||||
error= ret_error;
|
||||
DBUG_PRINT("info", ("Rename subpartition from %s to %s",
|
||||
part_name_buff, norm_name_buff));
|
||||
if ((ret_error= file->ha_rename_table(part_name_buff,
|
||||
@@ -873,32 +886,36 @@ int ha_partition::rename_partitions(const char *path)
|
||||
}
|
||||
else
|
||||
{
|
||||
create_partition_name(norm_name_buff, path,
|
||||
part_elem->partition_name, NORMAL_PART_NAME,
|
||||
TRUE);
|
||||
if (part_elem->part_state == PART_IS_CHANGED)
|
||||
if ((ret_error= create_partition_name(norm_name_buff,
|
||||
sizeof(norm_name_buff), path,
|
||||
part_elem->partition_name, NORMAL_PART_NAME, TRUE)) ||
|
||||
(ret_error= create_partition_name(part_name_buff,
|
||||
sizeof(part_name_buff), path,
|
||||
part_elem->partition_name, TEMP_PART_NAME, TRUE)))
|
||||
error= ret_error;
|
||||
else
|
||||
{
|
||||
file= m_reorged_file[part_count++];
|
||||
DBUG_PRINT("info", ("Delete partition %s", norm_name_buff));
|
||||
if ((ret_error= file->ha_delete_table(norm_name_buff)))
|
||||
if (part_elem->part_state == PART_IS_CHANGED)
|
||||
{
|
||||
file= m_reorged_file[part_count++];
|
||||
DBUG_PRINT("info", ("Delete partition %s", norm_name_buff));
|
||||
if ((ret_error= file->ha_delete_table(norm_name_buff)))
|
||||
error= ret_error;
|
||||
else if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos))
|
||||
error= 1;
|
||||
(void) sync_ddl_log();
|
||||
}
|
||||
file= m_new_file[i];
|
||||
DBUG_PRINT("info", ("Rename partition from %s to %s",
|
||||
part_name_buff, norm_name_buff));
|
||||
if ((ret_error= file->ha_rename_table(part_name_buff,
|
||||
norm_name_buff)))
|
||||
error= ret_error;
|
||||
else if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos))
|
||||
error= 1;
|
||||
(void) sync_ddl_log();
|
||||
else
|
||||
part_elem->log_entry= NULL;
|
||||
}
|
||||
file= m_new_file[i];
|
||||
create_partition_name(part_name_buff, path,
|
||||
part_elem->partition_name, TEMP_PART_NAME,
|
||||
TRUE);
|
||||
DBUG_PRINT("info", ("Rename partition from %s to %s",
|
||||
part_name_buff, norm_name_buff));
|
||||
if ((ret_error= file->ha_rename_table(part_name_buff,
|
||||
norm_name_buff)))
|
||||
error= ret_error;
|
||||
else if (deactivate_ddl_log_entry(part_elem->log_entry->entry_pos))
|
||||
error= 1;
|
||||
else
|
||||
part_elem->log_entry= NULL;
|
||||
}
|
||||
}
|
||||
} while (++i < num_parts);
|
||||
@@ -1494,7 +1511,7 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
|
||||
{
|
||||
List_iterator<partition_element> part_it(m_part_info->partitions);
|
||||
List_iterator <partition_element> t_it(m_part_info->temp_partitions);
|
||||
char part_name_buff[FN_REFLEN];
|
||||
char part_name_buff[FN_REFLEN + 1];
|
||||
uint num_parts= m_part_info->partitions.elements;
|
||||
uint num_subparts= m_part_info->num_subparts;
|
||||
uint i= 0;
|
||||
@@ -1704,10 +1721,14 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
|
||||
do
|
||||
{
|
||||
partition_element *sub_elem= sub_it++;
|
||||
create_subpartition_name(part_name_buff, path,
|
||||
part_elem->partition_name,
|
||||
sub_elem->partition_name,
|
||||
name_variant);
|
||||
if ((error= create_subpartition_name(part_name_buff,
|
||||
sizeof(part_name_buff), path,
|
||||
part_elem->partition_name, sub_elem->partition_name,
|
||||
name_variant)))
|
||||
{
|
||||
cleanup_new_partition(part_count);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
part= i * num_subparts + j;
|
||||
DBUG_PRINT("info", ("Add subpartition %s", part_name_buff));
|
||||
if ((error= prepare_new_partition(table, create_info,
|
||||
@@ -1725,9 +1746,14 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info,
|
||||
}
|
||||
else
|
||||
{
|
||||
create_partition_name(part_name_buff, path,
|
||||
part_elem->partition_name, name_variant,
|
||||
TRUE);
|
||||
if ((error= create_partition_name(part_name_buff,
|
||||
sizeof(part_name_buff), path, part_elem->partition_name,
|
||||
name_variant, TRUE)))
|
||||
{
|
||||
cleanup_new_partition(part_count);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
DBUG_PRINT("info", ("Add partition %s", part_name_buff));
|
||||
if ((error= prepare_new_partition(table, create_info,
|
||||
new_file_array[i],
|
||||
@@ -1986,8 +2012,8 @@ int ha_partition::del_ren_cre_table(const char *from,
|
||||
{
|
||||
int save_error= 0;
|
||||
int error= HA_ERR_INTERNAL_ERROR;
|
||||
char from_buff[FN_REFLEN], to_buff[FN_REFLEN], from_lc_buff[FN_REFLEN],
|
||||
to_lc_buff[FN_REFLEN], buff[FN_REFLEN];
|
||||
char from_buff[FN_REFLEN + 1], to_buff[FN_REFLEN + 1],
|
||||
from_lc_buff[FN_REFLEN], to_lc_buff[FN_REFLEN], buff[FN_REFLEN];
|
||||
char *name_buffer_ptr;
|
||||
const char *from_path;
|
||||
const char *to_path= NULL;
|
||||
@@ -2034,13 +2060,15 @@ int ha_partition::del_ren_cre_table(const char *from,
|
||||
i= 0;
|
||||
do
|
||||
{
|
||||
create_partition_name(from_buff, from_path, name_buffer_ptr,
|
||||
NORMAL_PART_NAME, FALSE);
|
||||
if ((error= create_partition_name(from_buff, sizeof(from_buff), from_path,
|
||||
name_buffer_ptr, NORMAL_PART_NAME, FALSE)))
|
||||
goto rename_error;
|
||||
|
||||
if (to != NULL)
|
||||
{ // Rename branch
|
||||
create_partition_name(to_buff, to_path, name_buffer_ptr,
|
||||
NORMAL_PART_NAME, FALSE);
|
||||
if ((error= create_partition_name(to_buff, sizeof(to_buff), to_path,
|
||||
name_buffer_ptr, NORMAL_PART_NAME, FALSE)))
|
||||
goto rename_error;
|
||||
error= (*file)->ha_rename_table(from_buff, to_buff);
|
||||
if (error)
|
||||
goto rename_error;
|
||||
@@ -2087,9 +2115,9 @@ create_error:
|
||||
name_buffer_ptr= m_name_buffer_ptr;
|
||||
for (abort_file= file, file= m_file; file < abort_file; file++)
|
||||
{
|
||||
create_partition_name(from_buff, from_path, name_buffer_ptr, NORMAL_PART_NAME,
|
||||
FALSE);
|
||||
(void) (*file)->ha_delete_table((const char*) from_buff);
|
||||
if (!create_partition_name(from_buff, sizeof(from_buff), from_path,
|
||||
name_buffer_ptr, NORMAL_PART_NAME, FALSE))
|
||||
(void) (*file)->ha_delete_table(from_buff);
|
||||
name_buffer_ptr= strend(name_buffer_ptr) + 1;
|
||||
}
|
||||
DBUG_RETURN(error);
|
||||
@@ -2098,12 +2126,11 @@ rename_error:
|
||||
for (abort_file= file, file= m_file; file < abort_file; file++)
|
||||
{
|
||||
/* Revert the rename, back from 'to' to the original 'from' */
|
||||
create_partition_name(from_buff, from_path, name_buffer_ptr,
|
||||
NORMAL_PART_NAME, FALSE);
|
||||
create_partition_name(to_buff, to_path, name_buffer_ptr,
|
||||
NORMAL_PART_NAME, FALSE);
|
||||
/* Ignore error here */
|
||||
(void) (*file)->ha_rename_table(to_buff, from_buff);
|
||||
if (!create_partition_name(from_buff, sizeof(from_buff), from_path,
|
||||
name_buffer_ptr, NORMAL_PART_NAME, FALSE) &&
|
||||
!create_partition_name(to_buff, sizeof(to_buff), to_path, name_buffer_ptr,
|
||||
NORMAL_PART_NAME, FALSE))
|
||||
(void) (*file)->ha_rename_table(to_buff, from_buff);
|
||||
name_buffer_ptr= strend(name_buffer_ptr) + 1;
|
||||
}
|
||||
DBUG_RETURN(error);
|
||||
@@ -2901,7 +2928,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
|
||||
char *name_buffer_ptr;
|
||||
int error= HA_ERR_INITIALIZATION;
|
||||
handler **file;
|
||||
char name_buff[FN_REFLEN];
|
||||
char name_buff[FN_REFLEN + 1];
|
||||
bool is_not_tmp_table= (table_share->tmp_table == NO_TMP_TABLE);
|
||||
ulonglong check_table_flags;
|
||||
DBUG_ENTER("ha_partition::open");
|
||||
@@ -2971,8 +2998,9 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
|
||||
file= m_is_clone_of->m_file;
|
||||
for (i= 0; i < m_tot_parts; i++)
|
||||
{
|
||||
create_partition_name(name_buff, name, name_buffer_ptr, NORMAL_PART_NAME,
|
||||
FALSE);
|
||||
if ((error= create_partition_name(name_buff, sizeof(name_buff), name,
|
||||
name_buffer_ptr, NORMAL_PART_NAME, FALSE)))
|
||||
goto err_handler;
|
||||
if (!(m_file[i]= file[i]->clone(name_buff, m_clone_mem_root)))
|
||||
{
|
||||
error= HA_ERR_INITIALIZATION;
|
||||
@@ -2987,8 +3015,9 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked)
|
||||
file= m_file;
|
||||
do
|
||||
{
|
||||
create_partition_name(name_buff, name, name_buffer_ptr, NORMAL_PART_NAME,
|
||||
FALSE);
|
||||
if ((error= create_partition_name(name_buff, sizeof(name_buff), name,
|
||||
name_buffer_ptr, NORMAL_PART_NAME, FALSE)))
|
||||
goto err_handler;
|
||||
table->s->connect_string = m_connect_string[(uint)(file-m_file)];
|
||||
if ((error= (*file)->ha_open(table, name_buff, mode, test_if_locked)))
|
||||
goto err_handler;
|
||||
|
||||
12
sql/item.cc
12
sql/item.cc
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
|
||||
Copyright (c) 2010, 2016, MariaDB
|
||||
Copyright (c) 2010, 2017, MariaDB Corporation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -817,6 +817,7 @@ Item_ident::Item_ident(Name_resolution_context *context_arg,
|
||||
cached_table(0), depended_from(0), can_be_depended(TRUE)
|
||||
{
|
||||
name = (char*) field_name_arg;
|
||||
name_length= name ? strlen(name) : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -829,6 +830,7 @@ Item_ident::Item_ident(TABLE_LIST *view_arg, const char *field_name_arg)
|
||||
cached_table(NULL), depended_from(NULL), can_be_depended(TRUE)
|
||||
{
|
||||
name = (char*) field_name_arg;
|
||||
name_length= name ? strlen(name) : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -4622,7 +4624,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
|
||||
int cur_match_degree= 0;
|
||||
|
||||
/* SELECT list element with explicit alias */
|
||||
if ((*(cur_group->item))->name &&
|
||||
if ((*(cur_group->item))->name && !table_name &&
|
||||
!(*(cur_group->item))->is_autogenerated_name &&
|
||||
!my_strcasecmp(system_charset_info,
|
||||
(*(cur_group->item))->name, field_name))
|
||||
@@ -5045,6 +5047,12 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference)
|
||||
((ref_type == REF_ITEM || ref_type == FIELD_ITEM) ?
|
||||
(Item_ident*) (*reference) :
|
||||
0));
|
||||
if (thd->lex->in_sum_func &&
|
||||
thd->lex->in_sum_func->nest_level >= select->nest_level)
|
||||
{
|
||||
set_if_bigger(thd->lex->in_sum_func->max_arg_level,
|
||||
select->nest_level);
|
||||
}
|
||||
/*
|
||||
A reference to a view field had been found and we
|
||||
substituted it instead of this Item (find_field_in_tables
|
||||
|
||||
@@ -1165,7 +1165,11 @@ public:
|
||||
longlong val_int();
|
||||
const char *func_name() const { return "coercibility"; }
|
||||
void fix_length_and_dec() { max_length=10; maybe_null= 0; }
|
||||
table_map not_null_tables() const { return 0; }
|
||||
bool eval_not_null_tables(uchar *opt_arg)
|
||||
{
|
||||
not_null_tables_cache= 0;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
class Item_func_locate :public Item_int_func
|
||||
@@ -1433,7 +1437,11 @@ public:
|
||||
}
|
||||
void cleanup();
|
||||
Item_result result_type () const { return udf.result_type(); }
|
||||
table_map not_null_tables() const { return 0; }
|
||||
bool eval_not_null_tables(uchar *opt_arg)
|
||||
{
|
||||
not_null_tables_cache= 0;
|
||||
return 0;
|
||||
}
|
||||
bool is_expensive() { return 1; }
|
||||
virtual void print(String *str, enum_query_type query_type);
|
||||
};
|
||||
@@ -1889,7 +1897,11 @@ public:
|
||||
bool is_expensive_processor(uchar *arg) { return TRUE; }
|
||||
enum Functype functype() const { return FT_FUNC; }
|
||||
const char *func_name() const { return "match"; }
|
||||
table_map not_null_tables() const { return 0; }
|
||||
bool eval_not_null_tables(uchar *opt_arg)
|
||||
{
|
||||
not_null_tables_cache= 0;
|
||||
return 0;
|
||||
}
|
||||
bool fix_fields(THD *thd, Item **ref);
|
||||
bool eq(const Item *, bool binary_cmp) const;
|
||||
/* The following should be safe, even if we compare doubles */
|
||||
@@ -2091,6 +2103,11 @@ public:
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
bool eval_not_null_tables(uchar *opt_arg)
|
||||
{
|
||||
not_null_tables_cache= 0;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2138,7 +2155,11 @@ public:
|
||||
void fix_length_and_dec();
|
||||
enum Item_result result_type () const { return last_value->result_type(); }
|
||||
const char *func_name() const { return "last_value"; }
|
||||
table_map not_null_tables() const { return 0; }
|
||||
bool eval_not_null_tables(uchar *opt_arg)
|
||||
{
|
||||
not_null_tables_cache= 0;
|
||||
return 0;
|
||||
}
|
||||
enum_field_types field_type() const { return last_value->field_type(); }
|
||||
bool const_item() const { return 0; }
|
||||
void evaluate_sideeffects();
|
||||
|
||||
@@ -316,7 +316,8 @@ bool Item_subselect::enumerate_field_refs_processor(uchar *arg)
|
||||
|
||||
while ((upper= it++))
|
||||
{
|
||||
if (upper->item->walk(&Item::enumerate_field_refs_processor, FALSE, arg))
|
||||
if (upper->item &&
|
||||
upper->item->walk(&Item::enumerate_field_refs_processor, FALSE, arg))
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@@ -1366,7 +1367,7 @@ Item_in_subselect::Item_in_subselect(Item * left_exp,
|
||||
Item_exists_subselect(),
|
||||
left_expr_cache(0), first_execution(TRUE), in_strategy(SUBS_NOT_TRANSFORMED),
|
||||
optimizer(0), pushed_cond_guards(NULL), emb_on_expr_nest(NULL),
|
||||
is_jtbm_merged(FALSE), is_jtbm_const_tab(FALSE),
|
||||
do_not_convert_to_sj(FALSE), is_jtbm_merged(FALSE), is_jtbm_const_tab(FALSE),
|
||||
is_flattenable_semijoin(FALSE),
|
||||
is_registered_semijoin(FALSE),
|
||||
upper_item(0)
|
||||
@@ -2493,6 +2494,27 @@ bool Item_in_subselect::inject_in_to_exists_cond(JOIN *join_arg)
|
||||
DBUG_ENTER("Item_in_subselect::inject_in_to_exists_cond");
|
||||
DBUG_ASSERT(thd == join_arg->thd);
|
||||
|
||||
if (select_lex->min_max_opt_list.elements)
|
||||
{
|
||||
/*
|
||||
MIN/MAX optimizations have been applied to Item_sum objects
|
||||
of the subquery this subquery predicate in opt_sum_query().
|
||||
Injection of new condition invalidates this optimizations.
|
||||
Thus those optimizations must be rolled back.
|
||||
*/
|
||||
List_iterator_fast<Item_sum> it(select_lex->min_max_opt_list);
|
||||
Item_sum *item;
|
||||
while ((item= it++))
|
||||
{
|
||||
item->clear();
|
||||
item->reset_forced_const();
|
||||
}
|
||||
if (where_item)
|
||||
where_item->update_used_tables();
|
||||
if (having_item)
|
||||
having_item->update_used_tables();
|
||||
}
|
||||
|
||||
if (where_item)
|
||||
{
|
||||
List<Item> *and_args= NULL;
|
||||
@@ -2850,7 +2872,8 @@ bool Item_in_subselect::init_cond_guards()
|
||||
{
|
||||
DBUG_ASSERT(thd);
|
||||
uint cols_num= left_expr->cols();
|
||||
if (!abort_on_null && left_expr->maybe_null && !pushed_cond_guards)
|
||||
if (!abort_on_null && !pushed_cond_guards &&
|
||||
(left_expr->maybe_null || cols_num > 1))
|
||||
{
|
||||
if (!(pushed_cond_guards= (bool*)thd->alloc(sizeof(bool) * cols_num)))
|
||||
return TRUE;
|
||||
|
||||
@@ -466,6 +466,8 @@ public:
|
||||
NULL - for all other locations
|
||||
*/
|
||||
TABLE_LIST *emb_on_expr_nest;
|
||||
/* May be TRUE only for the candidates to semi-join conversion */
|
||||
bool do_not_convert_to_sj;
|
||||
/*
|
||||
Types of left_expr and subquery's select list allow to perform subquery
|
||||
materialization. Currently, we set this to FALSE when it as well could
|
||||
@@ -554,9 +556,9 @@ public:
|
||||
Item_in_subselect()
|
||||
:Item_exists_subselect(), left_expr_cache(0), first_execution(TRUE),
|
||||
abort_on_null(0), in_strategy(SUBS_NOT_TRANSFORMED), optimizer(0),
|
||||
pushed_cond_guards(NULL), func(NULL), emb_on_expr_nest(NULL),
|
||||
is_jtbm_merged(FALSE), is_jtbm_const_tab(FALSE),
|
||||
upper_item(0)
|
||||
pushed_cond_guards(NULL), func(NULL), emb_on_expr_nest(NULL),
|
||||
do_not_convert_to_sj(FALSE), is_jtbm_merged(FALSE),
|
||||
is_jtbm_const_tab(FALSE), upper_item(0)
|
||||
{}
|
||||
void cleanup();
|
||||
subs_type substype() { return IN_SUBS; }
|
||||
@@ -617,6 +619,8 @@ public:
|
||||
emb_on_expr_nest= embedding;
|
||||
}
|
||||
|
||||
void block_conversion_to_sj () { do_not_convert_to_sj= TRUE; }
|
||||
|
||||
bool test_strategy(uchar strategy)
|
||||
{ return test(in_strategy & strategy); }
|
||||
|
||||
|
||||
@@ -454,6 +454,7 @@ public:
|
||||
used_tables_cache= 0;
|
||||
forced_const= TRUE;
|
||||
}
|
||||
void reset_forced_const() { forced_const= FALSE; }
|
||||
virtual bool const_item() const { return forced_const; }
|
||||
virtual bool const_during_execution() const { return false; }
|
||||
virtual void print(String *str, enum_query_type query_type);
|
||||
|
||||
@@ -3041,7 +3041,7 @@ get_date_time_result_type(const char *format, uint length)
|
||||
const char *val= format;
|
||||
const char *end= format + length;
|
||||
|
||||
for (; val != end && val != end; val++)
|
||||
for (; val != end; val++)
|
||||
{
|
||||
if (*val == '%' && val+1 != end)
|
||||
{
|
||||
|
||||
@@ -4995,13 +4995,20 @@ int THD::binlog_write_table_map(TABLE *table, bool is_transactional,
|
||||
|
||||
IO_CACHE *file=
|
||||
cache_mngr->get_binlog_cache_log(use_trans_cache(this, is_transactional));
|
||||
binlog_cache_data *cache_data=
|
||||
cache_mngr->get_binlog_cache_data(use_trans_cache(this, is_transactional));
|
||||
|
||||
if (with_annotate && *with_annotate)
|
||||
{
|
||||
Annotate_rows_log_event anno(current_thd, is_transactional, false);
|
||||
/* Annotate event should be written not more than once */
|
||||
*with_annotate= 0;
|
||||
if ((error= anno.write(file)))
|
||||
{
|
||||
if (my_errno == EFBIG)
|
||||
cache_data->set_incident();
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
}
|
||||
if ((error= the_event.write(file)))
|
||||
DBUG_RETURN(error);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
|
||||
Copyright (c) 2012, 2016, MariaDB
|
||||
Copyright (c) 2012, 2017, MariaDB Corporation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -678,6 +678,7 @@ int check_and_do_in_subquery_rewrites(JOIN *join)
|
||||
!((join->select_options | // 10
|
||||
select_lex->outer_select()->join->select_options) // 10
|
||||
& SELECT_STRAIGHT_JOIN)) // 10
|
||||
|
||||
{
|
||||
DBUG_PRINT("info", ("Subquery is semi-join conversion candidate"));
|
||||
|
||||
@@ -1000,6 +1001,25 @@ bool check_for_outer_joins(List<TABLE_LIST> *join_list)
|
||||
}
|
||||
|
||||
|
||||
void find_and_block_conversion_to_sj(Item *to_find,
|
||||
List_iterator_fast<Item_in_subselect> &li)
|
||||
{
|
||||
if (to_find->type() != Item::SUBSELECT_ITEM ||
|
||||
((Item_subselect *) to_find)->substype() != Item_subselect::IN_SUBS)
|
||||
return;
|
||||
Item_in_subselect *in_subq;
|
||||
li.rewind();
|
||||
while ((in_subq= li++))
|
||||
{
|
||||
if (in_subq == to_find)
|
||||
{
|
||||
in_subq->block_conversion_to_sj();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Convert semi-join subquery predicates into semi-join join nests
|
||||
|
||||
@@ -1052,7 +1072,6 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
|
||||
Query_arena *arena, backup;
|
||||
Item_in_subselect *in_subq;
|
||||
THD *thd= join->thd;
|
||||
List_iterator<TABLE_LIST> ti(join->select_lex->leaf_tables);
|
||||
DBUG_ENTER("convert_join_subqueries_to_semijoins");
|
||||
|
||||
if (join->select_lex->sj_subselects.is_empty())
|
||||
@@ -1070,6 +1089,89 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
|
||||
subq_sel->update_used_tables();
|
||||
}
|
||||
|
||||
/*
|
||||
Check all candidates to semi-join conversion that occur
|
||||
in ON expressions of outer join. Set the flag blocking
|
||||
this conversion for them.
|
||||
*/
|
||||
TABLE_LIST *tbl;
|
||||
List_iterator<TABLE_LIST> ti(join->select_lex->leaf_tables);
|
||||
while ((tbl= ti++))
|
||||
{
|
||||
TABLE_LIST *embedded;
|
||||
TABLE_LIST *embedding= tbl;
|
||||
do
|
||||
{
|
||||
embedded= embedding;
|
||||
bool block_conversion_to_sj= false;
|
||||
if (embedded->on_expr)
|
||||
{
|
||||
/*
|
||||
Conversion of an IN subquery predicate into semi-join
|
||||
is blocked now if the predicate occurs:
|
||||
- in the ON expression of an outer join
|
||||
- in the ON expression of an inner join embedded directly
|
||||
or indirectly in the inner nest of an outer join
|
||||
*/
|
||||
for (TABLE_LIST *tl= embedded; tl; tl= tl->embedding)
|
||||
{
|
||||
if (tl->outer_join)
|
||||
{
|
||||
block_conversion_to_sj= true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (block_conversion_to_sj)
|
||||
{
|
||||
Item *cond= embedded->on_expr;
|
||||
if (!cond)
|
||||
;
|
||||
else if (cond->type() != Item::COND_ITEM)
|
||||
find_and_block_conversion_to_sj(cond, li);
|
||||
else if (((Item_cond*) cond)->functype() ==
|
||||
Item_func::COND_AND_FUNC)
|
||||
{
|
||||
Item *item;
|
||||
List_iterator<Item> it(*(((Item_cond*) cond)->argument_list()));
|
||||
while ((item= it++))
|
||||
{
|
||||
find_and_block_conversion_to_sj(item, li);
|
||||
}
|
||||
}
|
||||
}
|
||||
embedding= embedded->embedding;
|
||||
}
|
||||
while (embedding &&
|
||||
embedding->nested_join->join_list.head() == embedded);
|
||||
}
|
||||
|
||||
/*
|
||||
Block conversion to semi-joins for those candidates that
|
||||
are encountered in the WHERE condition of the multi-table view
|
||||
with CHECK OPTION if this view is used in UPDATE/DELETE.
|
||||
(This limitation can be, probably, easily lifted.)
|
||||
*/
|
||||
li.rewind();
|
||||
while ((in_subq= li++))
|
||||
{
|
||||
if (in_subq->emb_on_expr_nest != NO_JOIN_NEST &&
|
||||
in_subq->emb_on_expr_nest->effective_with_check)
|
||||
{
|
||||
in_subq->block_conversion_to_sj();
|
||||
}
|
||||
}
|
||||
|
||||
if (join->select_options & SELECT_STRAIGHT_JOIN)
|
||||
{
|
||||
/* Block conversion to semijoins for all candidates */
|
||||
li.rewind();
|
||||
while ((in_subq= li++))
|
||||
{
|
||||
in_subq->block_conversion_to_sj();
|
||||
}
|
||||
}
|
||||
|
||||
li.rewind();
|
||||
/* First, convert child join's subqueries. We proceed bottom-up here */
|
||||
while ((in_subq= li++))
|
||||
@@ -1088,8 +1190,10 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
|
||||
|
||||
if (convert_join_subqueries_to_semijoins(child_join))
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
|
||||
in_subq->sj_convert_priority=
|
||||
test(in_subq->emb_on_expr_nest != NO_JOIN_NEST) * MAX_TABLES * 2 +
|
||||
test(in_subq->do_not_convert_to_sj) * MAX_TABLES * 2 +
|
||||
in_subq->is_correlated * MAX_TABLES + child_join->outer_tables;
|
||||
}
|
||||
|
||||
@@ -1122,7 +1226,7 @@ bool convert_join_subqueries_to_semijoins(JOIN *join)
|
||||
bool remove_item= TRUE;
|
||||
|
||||
/* Stop processing if we've reached a subquery that's attached to the ON clause */
|
||||
if (in_subq->emb_on_expr_nest != NO_JOIN_NEST)
|
||||
if (in_subq->do_not_convert_to_sj)
|
||||
break;
|
||||
|
||||
if (in_subq->is_flattenable_semijoin)
|
||||
@@ -3325,6 +3429,7 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
|
||||
table_map remaining_tables= 0;
|
||||
table_map handled_tabs= 0;
|
||||
join->sjm_lookup_tables= 0;
|
||||
join->sjm_scan_tables= 0;
|
||||
for (tablenr= table_count - 1 ; tablenr != join->const_tables - 1; tablenr--)
|
||||
{
|
||||
POSITION *pos= join->best_positions + tablenr;
|
||||
@@ -3383,6 +3488,9 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
|
||||
for (i= tablenr; i != (first + sjm->tables - 1); i--)
|
||||
rem_tables |= join->best_positions[i].table->table->map;
|
||||
|
||||
for (i= first; i < first+ sjm->tables; i++)
|
||||
join->sjm_scan_tables |= join->best_positions[i].table->table->map;
|
||||
|
||||
POSITION dummy;
|
||||
join->cur_sj_inner_tables= 0;
|
||||
for (i= first + sjm->tables; i <= tablenr; i++)
|
||||
|
||||
@@ -253,6 +253,8 @@ int opt_sum_query(THD *thd,
|
||||
int error= 0;
|
||||
DBUG_ENTER("opt_sum_query");
|
||||
|
||||
thd->lex->current_select->min_max_opt_list.empty();
|
||||
|
||||
if (conds)
|
||||
where_tables= conds->used_tables();
|
||||
|
||||
@@ -444,7 +446,14 @@ int opt_sum_query(THD *thd,
|
||||
item_sum->aggregator_clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
item_sum->reset_and_add();
|
||||
/*
|
||||
Save a reference to the item for possible rollback
|
||||
of the min/max optimizations for this select
|
||||
*/
|
||||
thd->lex->current_select->min_max_opt_list.push_back(item_sum);
|
||||
}
|
||||
item_sum->make_const();
|
||||
recalc_const_item= 1;
|
||||
break;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
Copyright (c) 2000, 2010, Oracle and/or its affiliates.
|
||||
Copyright (c) 2009, 2017, MariaDB Corporation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -260,7 +260,7 @@ int Binlog_storage_delegate::after_flush(THD *thd,
|
||||
thd->semisync_info= log_info;
|
||||
}
|
||||
|
||||
strcpy(log_info->log_file, log_file+dirname_length(log_file));
|
||||
strmake_buf(log_info->log_file, log_file+dirname_length(log_file));
|
||||
log_info->log_pos = log_pos;
|
||||
|
||||
FOREACH_OBSERVER(ret, after_flush, false,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user