summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysql.cc90
-rw-r--r--cmake/ssl.cmake7
-rw-r--r--debian/compat2
-rw-r--r--include/my_global.h7
-rw-r--r--include/my_sys.h2
-rw-r--r--libmysql/libmysql.c5
-rw-r--r--mysql-test/include/wait_for_slave_sql_error_and_skip.inc7
-rwxr-xr-xmysql-test/mysql-test-run.pl2
-rw-r--r--mysql-test/r/binary_to_hex.result117
-rw-r--r--mysql-test/r/count_distinct.result12
-rw-r--r--mysql-test/r/group_by.result27
-rw-r--r--mysql-test/r/loadxml.result16
-rw-r--r--mysql-test/r/read_only.result2
-rw-r--r--mysql-test/r/subselect.result8
-rw-r--r--mysql-test/r/subselect_no_mat.result8
-rw-r--r--mysql-test/r/subselect_no_opts.result8
-rw-r--r--mysql-test/r/subselect_no_scache.result8
-rw-r--r--mysql-test/r/subselect_no_semijoin.result8
-rw-r--r--mysql-test/r/subselect_nulls.result6
-rw-r--r--mysql-test/r/union.result18
-rw-r--r--mysql-test/r/view.result14
-rw-r--r--mysql-test/std_data/loadxml.dat8
-rw-r--r--mysql-test/suite/perfschema/t/privilege.test1
-rw-r--r--mysql-test/suite/rpl/r/rpl_reset_slave_fail.result29
-rw-r--r--mysql-test/suite/rpl/t/rpl_reset_slave_fail.test91
-rw-r--r--mysql-test/t/binary_to_hex.test76
-rw-r--r--mysql-test/t/count_distinct.test16
-rw-r--r--mysql-test/t/group_by.test38
-rw-r--r--mysql-test/t/read_only.test3
-rw-r--r--mysql-test/t/subselect.test10
-rw-r--r--mysql-test/t/subselect_nulls.test6
-rw-r--r--mysql-test/t/union.test15
-rw-r--r--mysql-test/t/view.test16
-rw-r--r--mysys/my_fopen.c2
-rw-r--r--mysys/stacktrace.c2
-rw-r--r--plugin/semisync/semisync_master.cc6
-rw-r--r--scripts/CMakeLists.txt11
-rw-r--r--[-rwxr-xr-x]scripts/dheadgen.pl8
-rw-r--r--scripts/mysql_config.pl.in4
-rw-r--r--scripts/mysql_convert_table_format.sh5
-rw-r--r--scripts/mysql_find_rows.sh5
-rw-r--r--scripts/mysql_fix_extensions.sh5
-rw-r--r--scripts/mysql_install_db.pl.in4
-rw-r--r--scripts/mysql_secure_installation.pl.in7
-rw-r--r--scripts/mysql_setpermission.sh5
-rw-r--r--scripts/mysql_zap.sh5
-rw-r--r--scripts/mysqlaccess.sh19
-rw-r--r--scripts/mysqld_multi.sh22
-rw-r--r--scripts/mysqldumpslow.sh5
-rw-r--r--scripts/mysqlhotcopy.sh4
-rw-r--r--sql/item.cc6
-rw-r--r--sql/item_subselect.cc6
-rw-r--r--sql/net_serv.cc2
-rw-r--r--sql/records.cc1
-rw-r--r--sql/rpl_handler.cc2
-rw-r--r--sql/rpl_mi.cc5
-rw-r--r--sql/rpl_rli.cc54
-rw-r--r--sql/rpl_rli.h12
-rw-r--r--sql/slave.cc5
-rw-r--r--sql/sql_derived.cc2
-rw-r--r--sql/sql_load.cc2
-rw-r--r--sql/sql_parse.cc31
-rw-r--r--sql/sql_repl.cc5
-rw-r--r--sql/sql_union.cc18
-rw-r--r--sql/uniques.cc16
-rw-r--r--storage/innobase/dict/dict0crea.cc1
-rw-r--r--storage/maria/ma_check.c4
-rw-r--r--storage/maria/ma_recovery.c4
-rw-r--r--storage/myisam/mi_check.c4
-rw-r--r--storage/myisam/mysql-test/storage_engine/parts/disabled.def0
70 files changed, 817 insertions, 165 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 9b5a9fb8aaa..1ff9fb9af6c 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -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;
@@ -1494,6 +1494,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},
@@ -3318,7 +3320,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);
@@ -3537,6 +3540,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)
{
@@ -3563,6 +3601,8 @@ print_table_data(MYSQL_RES *result)
length= MY_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,'-');
@@ -3630,9 +3670,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
{
@@ -3766,11 +3808,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);
@@ -3806,7 +3852,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
@@ -3853,23 +3902,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()
@@ -4006,11 +4060,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);
}
diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake
index f9daa29f4b9..c5985a38621 100644
--- a/cmake/ssl.cmake
+++ b/cmake/ssl.cmake
@@ -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
# We support different versions of SSL:
# - "bundled" uses source code in <source dir>/extra/yassl
@@ -206,7 +207,7 @@ MACRO (MYSQL_CHECK_SSL)
HAVE_ERR_remove_thread_state)
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()
diff --git a/debian/compat b/debian/compat
index 7ed6ff82de6..ec635144f60 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-5
+9
diff --git a/include/my_global.h b/include/my_global.h
index a61fd765995..ad78303add7 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -1,6 +1,6 @@
/*
Copyright (c) 2001, 2013, Oracle and/or its affiliates.
- Copyright (c) 2010, 2013, 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
@@ -439,9 +439,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
diff --git a/include/my_sys.h b/include/my_sys.h
index 22ed7616f1c..9e18373fe15 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -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
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index c07fad38802..4db60313775 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2014, Oracle and/or its affiliates.
- Copyright (c) 2009, 2014, SkySQL Ab.
+/* Copyright (c) 2000, 2014, 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
@@ -4927,4 +4927,3 @@ ulong STDCALL mysql_net_field_length(uchar **packet)
{
return net_field_length(packet);
}
-
diff --git a/mysql-test/include/wait_for_slave_sql_error_and_skip.inc b/mysql-test/include/wait_for_slave_sql_error_and_skip.inc
index 9246c1839af..d68faaf04e7 100644
--- a/mysql-test/include/wait_for_slave_sql_error_and_skip.inc
+++ b/mysql-test/include/wait_for_slave_sql_error_and_skip.inc
@@ -66,6 +66,13 @@ if (!$slave_skip_counter) {
}
source include/start_slave.inc;
+# start_slave.inc returns when Slave_SQL_Running=Yes. But the slave
+# thread sets it before clearing Last_SQL_Errno. So we have to wait
+# for Last_SQL_Errno=0 separately.
+
+let $slave_param= Last_SQL_Errno;
+let $slave_param_value= 0;
+source include/wait_for_slave_param.inc;
--let $include_filename= wait_for_slave_sql_error_and_skip.inc [errno=$slave_sql_errno]
--source include/end_include_file.inc
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 750722ea5a5..6b0c3b370de 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -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
diff --git a/mysql-test/r/binary_to_hex.result b/mysql-test/r/binary_to_hex.result
new file mode 100644
index 00000000000..a6b68834da8
--- /dev/null
+++ b/mysql-test/r/binary_to_hex.result
@@ -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;
diff --git a/mysql-test/r/count_distinct.result b/mysql-test/r/count_distinct.result
index 3b65dd0e608..d55a232c715 100644
--- a/mysql-test/r/count_distinct.result
+++ b/mysql-test/r/count_distinct.result
@@ -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;
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index 7a105fa6172..aac2d833233 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -2531,6 +2531,33 @@ 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;
#
# Bug #58782
# Missing rows with SELECT .. WHERE .. IN subquery
diff --git a/mysql-test/r/loadxml.result b/mysql-test/r/loadxml.result
index 1128caf9122..250037f60b8 100644
--- a/mysql-test/r/loadxml.result
+++ b/mysql-test/r/loadxml.result
@@ -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
diff --git a/mysql-test/r/read_only.result b/mysql-test/r/read_only.result
index c9c569137b2..6e2e394caec 100644
--- a/mysql-test/r/read_only.result
+++ b/mysql-test/r/read_only.result
@@ -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;
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 7dae5e56ac0..ce38d6ee643 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -7171,3 +7171,11 @@ 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;
diff --git a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result
index 0e116a7d71f..30dcf56c091 100644
--- a/mysql-test/r/subselect_no_mat.result
+++ b/mysql-test/r/subselect_no_mat.result
@@ -7164,6 +7164,14 @@ 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%'
diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result
index 5794779bc31..62a304a0c74 100644
--- a/mysql-test/r/subselect_no_opts.result
+++ b/mysql-test/r/subselect_no_opts.result
@@ -7162,4 +7162,12 @@ 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;
diff --git a/mysql-test/r/subselect_no_scache.result b/mysql-test/r/subselect_no_scache.result
index efca324efe7..d9e3be284f0 100644
--- a/mysql-test/r/subselect_no_scache.result
+++ b/mysql-test/r/subselect_no_scache.result
@@ -7177,6 +7177,14 @@ 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%'
diff --git a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result
index 3896adbfdd2..839d76ddd0b 100644
--- a/mysql-test/r/subselect_no_semijoin.result
+++ b/mysql-test/r/subselect_no_semijoin.result
@@ -7162,5 +7162,13 @@ 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;
diff --git a/mysql-test/r/subselect_nulls.result b/mysql-test/r/subselect_nulls.result
index 584c184870d..08982371269 100644
--- a/mysql-test/r/subselect_nulls.result
+++ b/mysql-test/r/subselect_nulls.result
@@ -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
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index 5a6cd8907e9..fe2339db471 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -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
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 30c3aaba36e..1cff9f378f8 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -5619,6 +5619,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.
# -----------------------------------------------------------------
diff --git a/mysql-test/std_data/loadxml.dat b/mysql-test/std_data/loadxml.dat
index b72fac9da74..d5ccd4a1b13 100644
--- a/mysql-test/std_data/loadxml.dat
+++ b/mysql-test/std_data/loadxml.dat
@@ -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 -->
diff --git a/mysql-test/suite/perfschema/t/privilege.test b/mysql-test/suite/perfschema/t/privilege.test
index 926d90d6edc..47a68602fa4 100644
--- a/mysql-test/suite/perfschema/t/privilege.test
+++ b/mysql-test/suite/perfschema/t/privilege.test
@@ -333,4 +333,3 @@ UPDATE performance_schema.setup_consumers SET enabled = 'YES';
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";
-
diff --git a/mysql-test/suite/rpl/r/rpl_reset_slave_fail.result b/mysql-test/suite/rpl/r/rpl_reset_slave_fail.result
new file mode 100644
index 00000000000..fdfec62058f
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_reset_slave_fail.result
@@ -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
diff --git a/mysql-test/suite/rpl/t/rpl_reset_slave_fail.test b/mysql-test/suite/rpl/t/rpl_reset_slave_fail.test
new file mode 100644
index 00000000000..021dc76d50c
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_reset_slave_fail.test
@@ -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
diff --git a/mysql-test/t/binary_to_hex.test b/mysql-test/t/binary_to_hex.test
new file mode 100644
index 00000000000..8312a246d0c
--- /dev/null
+++ b/mysql-test/t/binary_to_hex.test
@@ -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
diff --git a/mysql-test/t/count_distinct.test b/mysql-test/t/count_distinct.test
index 10b4ac6f0e7..a00574b6cba 100644
--- a/mysql-test/t/count_distinct.test
+++ b/mysql-test/t/count_distinct.test
@@ -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
+#
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index 8ea2f923eb1..da8d3016942 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -1702,6 +1702,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
#
diff --git a/mysql-test/t/read_only.test b/mysql-test/t/read_only.test
index 8ea0f2db9b7..7862580d3b0 100644
--- a/mysql-test/t/read_only.test
+++ b/mysql-test/t/read_only.test
@@ -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;
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 7b18e6b4cf5..cdb278d9130 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -6052,3 +6052,13 @@ 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;
diff --git a/mysql-test/t/subselect_nulls.test b/mysql-test/t/subselect_nulls.test
index 4b08e773b17..3e7b2189ed5 100644
--- a/mysql-test/t/subselect_nulls.test
+++ b/mysql-test/t/subselect_nulls.test
@@ -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);
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index f4dc6a5d449..4a3c19b49ab 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -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
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index db48e1a7661..89f9c744a5f 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -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 # -----------------------------------------------------------------
diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c
index 4f14bc5aaef..f3d64845526 100644
--- a/mysys/my_fopen.c
+++ b/mysys/my_fopen.c
@@ -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().
diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c
index 746b99d6112..2b83c5d5479 100644
--- a/mysys/stacktrace.c
+++ b/mysys/stacktrace.c
@@ -766,7 +766,7 @@ int 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);
}
diff --git a/plugin/semisync/semisync_master.cc b/plugin/semisync/semisync_master.cc
index 12415484b82..d577bd6848f 100644
--- a/plugin/semisync/semisync_master.cc
+++ b/plugin/semisync/semisync_master.cc
@@ -554,7 +554,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;
@@ -662,7 +662,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++;
@@ -673,7 +673,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;
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index 79d87fcf6be..814ab163e5f 100644
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -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
@@ -96,6 +97,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")
@@ -378,4 +386,3 @@ IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_FLAGS MATCHES "-static")
COMPONENT Development)
ENDIF()
ENDIF()
-
diff --git a/scripts/dheadgen.pl b/scripts/dheadgen.pl
index c42bd49b32e..69ece2e7c81 100755..100644
--- a/scripts/dheadgen.pl
+++ b/scripts/dheadgen.pl
@@ -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:
diff --git a/scripts/mysql_config.pl.in b/scripts/mysql_config.pl.in
index d7b36ec9b09..f2c27bc0b84 100644
--- a/scripts/mysql_config.pl.in
+++ b/scripts/mysql_config.pl.in
@@ -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
diff --git a/scripts/mysql_convert_table_format.sh b/scripts/mysql_convert_table_format.sh
index 5f3e093d2b9..5042a742d55 100644
--- a/scripts/mysql_convert_table_format.sh
+++ b/scripts/mysql_convert_table_format.sh
@@ -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
diff --git a/scripts/mysql_find_rows.sh b/scripts/mysql_find_rows.sh
index 48c4915ae00..20c3e2c3106 100644
--- a/scripts/mysql_find_rows.sh
+++ b/scripts/mysql_find_rows.sh
@@ -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
diff --git a/scripts/mysql_fix_extensions.sh b/scripts/mysql_fix_extensions.sh
index 2a50bfe22bb..7aa07209d4d 100644
--- a/scripts/mysql_fix_extensions.sh
+++ b/scripts/mysql_fix_extensions.sh
@@ -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
diff --git a/scripts/mysql_install_db.pl.in b/scripts/mysql_install_db.pl.in
index ede5fabd3aa..c33fb269a3a 100644
--- a/scripts/mysql_install_db.pl.in
+++ b/scripts/mysql_install_db.pl.in
@@ -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
diff --git a/scripts/mysql_secure_installation.pl.in b/scripts/mysql_secure_installation.pl.in
index 32331c3d601..01d34c4af4d 100644
--- a/scripts/mysql_secure_installation.pl.in
+++ b/scripts/mysql_secure_installation.pl.in
@@ -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
-
-
-
diff --git a/scripts/mysql_setpermission.sh b/scripts/mysql_setpermission.sh
index 48f0b09b566..4416551eadd 100644
--- a/scripts/mysql_setpermission.sh
+++ b/scripts/mysql_setpermission.sh
@@ -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
diff --git a/scripts/mysql_zap.sh b/scripts/mysql_zap.sh
index a9c3e7a7f5a..725a4e247a4 100644
--- a/scripts/mysql_zap.sh
+++ b/scripts/mysql_zap.sh
@@ -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
diff --git a/scripts/mysqlaccess.sh b/scripts/mysqlaccess.sh
index 3626794d533..e1872bd0cf8 100644
--- a/scripts/mysqlaccess.sh
+++ b/scripts/mysqlaccess.sh
@@ -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,16 +477,23 @@ MySQLaccess::Report::Print_Header();
# *****************************
# Read configuration-file
MySQLaccess::Debug::Print(1, "Reading configuration file...");
- if (-f "./$script_conf") {
- require "./$script_conf";
+ if (-f "@sysconfdir@/$script_conf") {
+ print "Configuration file '$script_conf' is found in '@sysconfdir@/'\n";
+ require "@sysconfdir@/$script_conf";
}
elsif (-f "@prefix@/$script_conf") {
+ print "Configuration file '$script_conf' is found in '@prefix@/'\n";
require "@prefix@/$script_conf";
}
- elsif (-f "@sysconfdir@/$script_conf") {
- require "@sysconfdir@/$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 @prefix@/\n";
+ print "Please move it to one of these locations and retry.\n\n";
+ exit 0;
}
+
# ****************************
# Read in all parameters
if ($MySQLaccess::CMD) { #command-line version
diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh
index fc375fcd765..fa2743a9a9b 100644
--- a/scripts/mysqld_multi.sh
+++ b/scripts/mysqld_multi.sh
@@ -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
diff --git a/scripts/mysqldumpslow.sh b/scripts/mysqldumpslow.sh
index c04ffad7457..a7d064904a5 100644
--- a/scripts/mysqldumpslow.sh
+++ b/scripts/mysqldumpslow.sh
@@ -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
diff --git a/scripts/mysqlhotcopy.sh b/scripts/mysqlhotcopy.sh
index b6ff7e1b28d..d6184d9ef10 100644
--- a/scripts/mysqlhotcopy.sh
+++ b/scripts/mysqlhotcopy.sh
@@ -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
diff --git a/sql/item.cc b/sql/item.cc
index 5a6440213ed..6bd982f8854 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2016, Oracle and/or its affiliates.
- Copyright (c) 2010, 2017, 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
@@ -847,6 +847,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;
}
@@ -859,6 +860,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;
}
@@ -4565,7 +4567,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))
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 70b730a5a33..198657636f6 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -329,7 +329,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;
@@ -3327,7 +3328,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;
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index f52549bfd0b..90a5da6a927 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -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
diff --git a/sql/records.cc b/sql/records.cc
index 940fd97d123..f7d038f8650 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -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
diff --git a/sql/rpl_handler.cc b/sql/rpl_handler.cc
index 917a9d11b5a..d97e0e07f52 100644
--- a/sql/rpl_handler.cc
+++ b/sql/rpl_handler.cc
@@ -261,7 +261,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,
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index bdc88625c0d..7cb093c9026 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2006, 2012, Oracle and/or its affiliates.
- Copyright (c) 2010, 2011, Monty Program Ab
+/* Copyright (c) 2006, 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 General Public License as published by
@@ -709,7 +709,6 @@ void end_master_info(Master_info* mi)
if (!mi->inited)
DBUG_VOID_RETURN;
- end_relay_log_info(&mi->rli);
if (mi->fd >= 0)
{
end_io_cache(&mi->file);
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index 928fbd3d7c1..9e20775a1aa 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2006, 2013, Oracle and/or its affiliates.
- Copyright (c) 2010, 2013, Monty Program Ab
+/* 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
@@ -54,8 +54,8 @@ Relay_log_info::Relay_log_info(bool is_slave_recovery)
sync_counter(0), is_relay_log_recovery(is_slave_recovery),
save_temporary_tables(0), mi(0),
inuse_relaylog_list(0), last_inuse_relaylog(0),
- cur_log_old_open_count(0), group_relay_log_pos(0),
- event_relay_log_pos(0),
+ cur_log_old_open_count(0), error_on_rli_init_info(false),
+ group_relay_log_pos(0), event_relay_log_pos(0),
#if HAVE_valgrind
is_fake(FALSE),
#endif
@@ -119,7 +119,7 @@ int init_relay_log_info(Relay_log_info* rli,
const char* info_fname)
{
char fname[FN_REFLEN+128];
- int info_fd;
+ int info_fd= -1;
const char* msg = 0;
int error = 0;
DBUG_ENTER("init_relay_log_info");
@@ -129,6 +129,8 @@ int init_relay_log_info(Relay_log_info* rli,
DBUG_RETURN(0);
fn_format(fname, info_fname, mysql_data_home, "", 4+32);
mysql_mutex_lock(&rli->data_lock);
+ if (rli->error_on_rli_init_info)
+ goto err;
info_fd = rli->info_fd;
rli->cur_log_fd = -1;
rli->slave_skip_counter=0;
@@ -436,11 +438,14 @@ Failed to open the existing relay log info file '%s' (errno %d)",
goto err;
}
rli->inited= 1;
+ rli->error_on_rli_init_info= false;
mysql_mutex_unlock(&rli->data_lock);
DBUG_RETURN(0);
err:
- sql_print_error("%s", msg);
+ rli->error_on_rli_init_info= true;
+ if (msg)
+ sql_print_error("%s", msg);
end_io_cache(&rli->info_file);
if (info_fd >= 0)
mysql_file_close(info_fd, MYF(0));
@@ -1101,6 +1106,8 @@ int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset,
const char** errmsg)
{
int error=0;
+ const char *ln;
+ char name_buf[FN_REFLEN];
DBUG_ENTER("purge_relay_logs");
/*
@@ -1127,12 +1134,35 @@ int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset,
if (!rli->inited)
{
DBUG_PRINT("info", ("rli->inited == 0"));
- DBUG_RETURN(0);
- }
-
- DBUG_ASSERT(rli->slave_running == 0);
- DBUG_ASSERT(rli->mi->slave_running == 0);
+ if (rli->error_on_rli_init_info)
+ {
+ ln= rli->relay_log.generate_name(opt_relay_logname, "-relay-bin",
+ 1, name_buf);
+ if (rli->relay_log.open_index_file(opt_relaylog_index_name, ln, TRUE))
+ {
+ sql_print_error("Unable to purge relay log files. Failed to open relay "
+ "log index file:%s.", rli->relay_log.get_index_fname());
+ DBUG_RETURN(1);
+ }
+ if (rli->relay_log.open(ln, LOG_BIN, 0, SEQ_READ_APPEND,
+ (rli->max_relay_log_size ? rli->max_relay_log_size :
+ max_binlog_size), 1, TRUE))
+ {
+ sql_print_error("Unable to purge relay log files. Failed to open relay "
+ "log file:%s.", rli->relay_log.get_log_fname());
+ DBUG_RETURN(1);
+ }
+ }
+ else
+ DBUG_RETURN(0);
+ }
+ else
+ {
+ DBUG_ASSERT(rli->slave_running == 0);
+ DBUG_ASSERT(rli->mi->slave_running == 0);
+ }
+ rli->slave_skip_counter=0;
mysql_mutex_lock(&rli->data_lock);
/*
@@ -1179,6 +1209,8 @@ int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset,
rli->group_relay_log_name[0]= rli->event_relay_log_name[0]= 0;
}
+ if (!rli->inited && rli->error_on_rli_init_info)
+ rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT);
err:
#ifndef DBUG_OFF
char buf[22];
diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h
index 7fc41786957..e3f8e10a705 100644
--- a/sql/rpl_rli.h
+++ b/sql/rpl_rli.h
@@ -1,4 +1,5 @@
-/* Copyright (c) 2005, 2012, Oracle and/or its affiliates.
+/* Copyright (c) 2005, 2017, 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
@@ -176,7 +177,14 @@ public:
a different log under our feet
*/
uint32 cur_log_old_open_count;
-
+
+ /*
+ If on init_info() call error_on_rli_init_info is true that means
+ that previous call to init_info() terminated with an error, RESET
+ SLAVE must be executed and the problem fixed manually.
+ */
+ bool error_on_rli_init_info;
+
/*
Let's call a group (of events) :
- a transaction
diff --git a/sql/slave.cc b/sql/slave.cc
index 4e61c161a93..b00bee5acee 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
- Copyright (c) 2009, 2017, MariaDB
+/* Copyright (c) 2000, 2017, 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
@@ -6024,6 +6024,7 @@ void end_relay_log_info(Relay_log_info* rli)
mysql_mutex_t *log_lock;
DBUG_ENTER("end_relay_log_info");
+ rli->error_on_rli_init_info= false;
if (!rli->inited)
DBUG_VOID_RETURN;
if (rli->info_fd >= 0)
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index af5b016df9d..2ca97a32071 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -537,6 +537,8 @@ bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived)
DBUG_ASSERT(derived->table);
}
}
+ else
+ derived->table= derived->merge_underlying_list->table;
DBUG_RETURN(FALSE);
}
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index c391cfba00c..fe72d40b802 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.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
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index b054dd3f5ed..efcb218eb4c 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1045,20 +1045,16 @@ static my_bool deny_updates_if_read_only_option(THD *thd,
if (lex->sql_command == SQLCOM_UPDATE_MULTI)
DBUG_RETURN(FALSE);
- const my_bool create_temp_tables=
- (lex->sql_command == SQLCOM_CREATE_TABLE) &&
- lex->create_info.tmp_table();
-
- const my_bool drop_temp_tables=
- (lex->sql_command == SQLCOM_DROP_TABLE) &&
- lex->drop_temporary;
-
- const my_bool update_real_tables=
- some_non_temp_table_to_be_updated(thd, all_tables) &&
- !(create_temp_tables || drop_temp_tables);
-
+ /*
+ a table-to-be-created is not in the temp table list yet,
+ so CREATE TABLE needs a special treatment
+ */
+ const bool update_real_tables=
+ lex->sql_command == SQLCOM_CREATE_TABLE
+ ? !(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE)
+ : some_non_temp_table_to_be_updated(thd, all_tables);
- const my_bool create_or_drop_databases=
+ const bool create_or_drop_databases=
(lex->sql_command == SQLCOM_CREATE_DB) ||
(lex->sql_command == SQLCOM_DROP_DB);
@@ -1532,9 +1528,12 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
kill_zombie_dump_threads(slave_server_id);
thd->variables.server_id = slave_server_id;
- general_log_print(thd, command, "Log: '%s' Pos: %ld", packet+10,
- (long) pos);
- mysql_binlog_send(thd, thd->strdup(packet + 10), (my_off_t) pos, flags);
+ const char *name= packet + 10;
+ size_t nlen= strlen(name);
+
+ general_log_print(thd, command, "Log: '%s' Pos: %lu", name, pos);
+ if (nlen < FN_REFLEN)
+ mysql_binlog_send(thd, thd->strmake(name, nlen), (my_off_t)pos, flags);
unregister_slave(thd,1,1);
/* fake COM_QUIT -- if we get here, the thread needs to terminate */
error = TRUE;
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 0ddeeaa0266..a2acf52d44e 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
- Copyright (c) 2008, 2014, SkySQL Ab.
+/* Copyright (c) 2000, 2017, Oracle and/or its affiliates.
+ Copyright (c) 2008, 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
@@ -3142,6 +3142,7 @@ int reset_slave(THD *thd, Master_info* mi)
// close master_info_file, relay_log_info_file, set mi->inited=rli->inited=0
end_master_info(mi);
+ end_relay_log_info(&mi->rli);
// and delete these two files
create_logfile_name_with_suffix(master_info_file_tmp,
sizeof(master_info_file_tmp),
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index cfa907b9ddc..16de451211f 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2014, Oracle and/or its affiliates.
- Copyright (c) 2010, 2014, SkySQL Ab.
+/* Copyright (c) 2000, 2017, Oracle and/or its affiliates.
+ Copyright (c) 2010, 2017, 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
@@ -360,6 +360,19 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
Item *item_tmp;
while ((item_tmp= it++))
{
+ /*
+ If the outer query has a GROUP BY clause, an outer reference to this
+ query block may have been wrapped in a Item_outer_ref, which has not
+ been fixed yet. An Item_type_holder must be created based on a fixed
+ Item, so use the inner Item instead.
+ */
+ DBUG_ASSERT(item_tmp->fixed ||
+ (item_tmp->type() == Item::REF_ITEM &&
+ ((Item_ref *)(item_tmp))->ref_type() ==
+ Item_ref::OUTER_REF));
+ if (!item_tmp->fixed)
+ item_tmp= item_tmp->real_item();
+
/* Error's in 'new' will be detected after loop */
types.push_back(new Item_type_holder(thd_arg, item_tmp));
}
@@ -1076,4 +1089,3 @@ void st_select_lex_unit::set_unique_exclude()
}
}
}
-
diff --git a/sql/uniques.cc b/sql/uniques.cc
index c755293035b..31c00667440 100644
--- a/sql/uniques.cc
+++ b/sql/uniques.cc
@@ -483,7 +483,7 @@ void put_counter_into_merged_element(void *ptr, uint ofs, element_count cnt)
<> 0 error
*/
-static bool merge_walk(uchar *merge_buffer, ulong merge_buffer_size,
+static bool merge_walk(uchar *merge_buffer, size_t merge_buffer_size,
uint key_length, BUFFPEK *begin, BUFFPEK *end,
tree_walk_action walk_action, void *walk_action_arg,
qsort_cmp2 compare, void *compare_arg,
@@ -492,7 +492,7 @@ static bool merge_walk(uchar *merge_buffer, ulong merge_buffer_size,
BUFFPEK_COMPARE_CONTEXT compare_context = { compare, compare_arg };
QUEUE queue;
if (end <= begin ||
- merge_buffer_size < (ulong) (key_length * (end - begin + 1)) ||
+ merge_buffer_size < (size_t) (key_length * (end - begin + 1)) ||
init_queue(&queue, (uint) (end - begin), offsetof(BUFFPEK, key), 0,
buffpek_compare, &compare_context, 0, 0))
return 1;
@@ -642,15 +642,19 @@ bool Unique::walk(TABLE *table, tree_walk_action action, void *walk_action_arg)
return 1;
if (flush_io_cache(&file) || reinit_io_cache(&file, READ_CACHE, 0L, 0, 0))
return 1;
- size_t buff_sz= (max_in_memory_size / full_size + 1) * full_size;
+ /*
+ merge_buffer must fit at least MERGEBUFF2 keys, because
+ merge_index() can merge that many BUFFPEKs at once.
+ */
+ size_t buff_sz= MY_MAX(MERGEBUFF2, max_in_memory_size/full_size+1) * full_size;
if (!(merge_buffer = (uchar *)my_malloc(buff_sz, MYF(MY_THREAD_SPECIFIC|MY_WME))))
return 1;
if (buff_sz < full_size * (file_ptrs.elements + 1UL))
res= merge(table, merge_buffer, buff_sz >= full_size * MERGEBUFF2) ;
-
+
if (!res)
- {
- res= merge_walk(merge_buffer, (ulong) max_in_memory_size, full_size,
+ {
+ res= merge_walk(merge_buffer, buff_sz, full_size,
(BUFFPEK *) file_ptrs.buffer,
(BUFFPEK *) file_ptrs.buffer + file_ptrs.elements,
action, walk_action_arg,
diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc
index 3c140dbb07e..583b679428a 100644
--- a/storage/innobase/dict/dict0crea.cc
+++ b/storage/innobase/dict/dict0crea.cc
@@ -100,6 +100,7 @@ dict_create_sys_tables_tuple(
| ((table->flags & DICT_TF_COMPACT) << 31));
dfield_set_data(dfield, ptr, 4);
+
/* 5: TYPE (table flags) -----------------------------*/
dfield = dtuple_get_nth_field(
entry, DICT_COL__SYS_TABLES__TYPE);
diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c
index 851f21888d8..cd8cedeb092 100644
--- a/storage/maria/ma_check.c
+++ b/storage/maria/ma_check.c
@@ -4255,6 +4255,8 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
}
*/
DBUG_PRINT("info", ("is quick repair: %d", (int) rep_quick));
+ if (!rep_quick)
+ my_b_clear(&new_data_cache);
/* Initialize pthread structures before goto err. */
mysql_mutex_init(key_SORT_INFO_mutex, &sort_info.mutex, MY_MUTEX_INIT_FAST);
@@ -4614,7 +4616,7 @@ err:
already or they were not yet started (if the error happend before
creating the threads).
*/
- if (!rep_quick)
+ if (!rep_quick && my_b_inited(&new_data_cache))
end_io_cache(&new_data_cache);
if (!got_error)
{
diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c
index 5a36c9db8ca..0426f9803b5 100644
--- a/storage/maria/ma_recovery.c
+++ b/storage/maria/ma_recovery.c
@@ -887,9 +887,7 @@ prototype_redo_exec_hook(REDO_CREATE_TABLE)
if (create_database_if_not_exists(name))
goto end;
fn_format(filename, name, "", MARIA_NAME_IEXT,
- (MY_UNPACK_FILENAME |
- (flags & HA_DONT_TOUCH_DATA) ? MY_RETURN_REAL_PATH : 0) |
- MY_APPEND_EXT);
+ MY_UNPACK_FILENAME | MY_RETURN_REAL_PATH | MY_APPEND_EXT);
linkname_ptr= NULL;
create_flag= MY_DELETE_OLD;
tprint(tracef, "Table '%s' creating as '%s'\n", name, filename);
diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c
index bbe45aa3c26..6902ae00ccf 100644
--- a/storage/myisam/mi_check.c
+++ b/storage/myisam/mi_check.c
@@ -2680,6 +2680,8 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info,
*/
DBUG_PRINT("info", ("is quick repair: %d", rep_quick));
bzero((char*)&sort_info,sizeof(sort_info));
+ if (!rep_quick)
+ my_b_clear(&new_data_cache);
/* Initialize pthread structures before goto err. */
mysql_mutex_init(mi_key_mutex_MI_SORT_INFO_mutex,
&sort_info.mutex, MY_MUTEX_INIT_FAST);
@@ -3055,7 +3057,7 @@ err:
already or they were not yet started (if the error happend before
creating the threads).
*/
- if (!rep_quick)
+ if (!rep_quick && my_b_inited(&new_data_cache))
(void) end_io_cache(&new_data_cache);
if (!got_error)
{
diff --git a/storage/myisam/mysql-test/storage_engine/parts/disabled.def b/storage/myisam/mysql-test/storage_engine/parts/disabled.def
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/storage/myisam/mysql-test/storage_engine/parts/disabled.def