From 5abec3e3e3b9299b3d3cd857cc144d8bdcaf6890 Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Mon, 3 Mar 2014 15:10:30 +0100 Subject: [PATCH 01/25] Raise version number after cloning 5.5.37 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index df053fca509..a519214c0c5 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=5 MYSQL_VERSION_MINOR=5 -MYSQL_VERSION_PATCH=37 +MYSQL_VERSION_PATCH=38 MYSQL_VERSION_EXTRA= From a9db74f46ddbecfefa4497989dcfdaf6174b30b9 Mon Sep 17 00:00:00 2001 From: Namit Sharma Date: Tue, 4 Mar 2014 13:48:13 +0530 Subject: [PATCH 02/25] BUG#11754425 - rpl_innodb_bug28430 times out on certain pb2 hosts. Removed rpl_innodb_bug28430 from default.experimental as BUG can't be repeated --- mysql-test/collections/default.experimental | 1 - 1 file changed, 1 deletion(-) diff --git a/mysql-test/collections/default.experimental b/mysql-test/collections/default.experimental index 961a93b8741..82f8b49ff45 100644 --- a/mysql-test/collections/default.experimental +++ b/mysql-test/collections/default.experimental @@ -23,7 +23,6 @@ main.query_cache_28249 # Bug#12584161 2009-03-25 main.query_ca ndb.* # joro : NDB tests marked as experimental as agreed with bochklin -rpl.rpl_innodb_bug28430 # Bug#11754425 rpl.rpl_insert # Sven: BUG#12764817 rpl.rpl_row_sp011 @solaris # Joro : Bug #11753919 rpl.rpl_stop_slave # Sven : BUG#12345981 From 5295b21feb2d03a4ae929ce2d94ef86dbded213b Mon Sep 17 00:00:00 2001 From: Tor Didriksen Date: Tue, 4 Mar 2014 16:41:14 +0100 Subject: [PATCH 03/25] Bug#18305641 SOLARIS SPECIFIIC FILES INSTALLED ON ALL PLATFORMS Don't install solaris specific files on other platforms. --- packaging/solaris/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packaging/solaris/CMakeLists.txt b/packaging/solaris/CMakeLists.txt index 02881e0af8f..899847d0f38 100644 --- a/packaging/solaris/CMakeLists.txt +++ b/packaging/solaris/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2012, 2014, 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 @@ -17,6 +17,10 @@ # Any files in this directory are auxiliary files for Solaris "pkg" packages. # They will be configured during "pkg" creation, not during (binary) build. +IF(NOT CMAKE_SYSTEM_NAME MATCHES "SunOS") + RETURN() +ENDIF() + # Currently, this expands to "support-files/" in most layouts, # but to "/usr/share/mysql/" in a RPM. # It is important not to pollute "/usr/bin". From 2d5be2fc20cf13ac093bc379d90f1cb23f2eb67b Mon Sep 17 00:00:00 2001 From: Tor Didriksen Date: Wed, 5 Mar 2014 13:01:54 +0100 Subject: [PATCH 04/25] Backport of: Bug#17894997 CMAKE WARNING WRT INTERFACE_LINK_LIBRARIES Bug#17905155 CMAKE WARNING WHEN GENERATING MAKEFILE Bug#71089 CMake warning when generating Makefile Use old policy for LINK_INTERFACE_LIBRARIES. --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a0cae57bbf..60ecd3d7149 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,12 @@ if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.6) CMAKE_POLICY(VERSION 2.8) endif() +# We use PROPERTIES LINK_INTERFACE_LIBRARIES. See cmake --help-policy CMP0022 +IF(CMAKE_VERSION VERSION_EQUAL "2.8.12" OR + CMAKE_VERSION VERSION_GREATER "2.8.12") + CMAKE_POLICY(SET CMP0022 OLD) +ENDIF() + MESSAGE(STATUS "Running cmake version ${CMAKE_VERSION}") SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) From c8b8d00947e4e67ebaa87405dd48b93501c2d67d Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Mon, 17 Mar 2014 17:54:08 +0100 Subject: [PATCH 05/25] Bug#18319790 QUERY TO INFORMATION_SCHEMA CRASHES SERVER Before this fix, specially crafted queries using the INFORMATION_SCHEMA could crash the server. The root cause was a buffer overflow, see the (private) bug comments for details. With this fix, the buffer overflow condition is properly handled, and the queries involved do return the expected result. --- sql/sql_show.cc | 65 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index b8e8649e1eb..dcae4c63b02 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2014, 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 @@ -2394,10 +2394,38 @@ void calc_sum_of_all_status(STATUS_VAR *to) /* This is only used internally, but we need it here as a forward reference */ extern ST_SCHEMA_TABLE schema_tables[]; +/** + Condition pushdown used for INFORMATION_SCHEMA / SHOW queries. + This structure is to implement an optimization when + accessing data dictionary data in the INFORMATION_SCHEMA + or SHOW commands. + When the query contain a TABLE_SCHEMA or TABLE_NAME clause, + narrow the search for data based on the constraints given. +*/ typedef struct st_lookup_field_values { - LEX_STRING db_value, table_value; - bool wild_db_value, wild_table_value; + /** + Value of a TABLE_SCHEMA clause. + Note that this value length may exceed @c NAME_LEN. + @sa wild_db_value + */ + LEX_STRING db_value; + /** + Value of a TABLE_NAME clause. + Note that this value length may exceed @c NAME_LEN. + @sa wild_table_value + */ + LEX_STRING table_value; + /** + True when @c db_value is a LIKE clause, + false when @c db_value is an '=' clause. + */ + bool wild_db_value; + /** + True when @c table_value is a LIKE clause, + false when @c table_value is an '=' clause. + */ + bool wild_table_value; } LOOKUP_FIELD_VALUES; @@ -2801,14 +2829,22 @@ int make_db_list(THD *thd, List *files, /* - If we have db lookup vaule we just add it to list and + If we have db lookup value we just add it to list and exit from the function. We don't do this for database names longer than the maximum - path length. + name length. */ - if (lookup_field_vals->db_value.str && - lookup_field_vals->db_value.length < FN_REFLEN) + if (lookup_field_vals->db_value.str) { + if (lookup_field_vals->db_value.length > NAME_LEN) + { + /* + Impossible value for a database name, + found in a WHERE DATABASE_NAME = 'xxx' clause. + */ + return 0; + } + if (is_infoschema_db(lookup_field_vals->db_value.str, lookup_field_vals->db_value.length)) { @@ -2945,6 +2981,15 @@ make_table_name_list(THD *thd, List *table_names, LEX *lex, if (!lookup_field_vals->wild_table_value && lookup_field_vals->table_value.str) { + if (lookup_field_vals->table_value.length > NAME_LEN) + { + /* + Impossible value for a table name, + found in a WHERE TABLE_NAME = 'xxx' clause. + */ + return 0; + } + if (with_i_schema) { LEX_STRING *name; @@ -3411,6 +3456,9 @@ static int fill_schema_table_from_frm(THD *thd, TABLE_LIST *tables, bzero((char*) &table_list, sizeof(TABLE_LIST)); bzero((char*) &tbl, sizeof(TABLE)); + DBUG_ASSERT(db_name->length <= NAME_LEN); + DBUG_ASSERT(table_name->length <= NAME_LEN); + if (lower_case_table_names) { /* @@ -3742,6 +3790,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) it.rewind(); /* To get access to new elements in basis list */ while ((db_name= it++)) { + DBUG_ASSERT(db_name->length <= NAME_LEN); #ifndef NO_EMBEDDED_ACCESS_CHECKS if (!(check_access(thd, SELECT_ACL, db_name->str, &thd->col_access, NULL, 0, 1) || @@ -3763,6 +3812,7 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) List_iterator_fast it_files(table_names); while ((table_name= it_files++)) { + DBUG_ASSERT(table_name->length <= NAME_LEN); restore_record(table, s->default_values); table->field[schema_table->idx_field1]-> store(db_name->str, db_name->length, system_charset_info); @@ -3909,6 +3959,7 @@ int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond) List_iterator_fast it(db_names); while ((db_name=it++)) { + DBUG_ASSERT(db_name->length <= NAME_LEN); if (with_i_schema) // information schema name is always first in list { if (store_schema_shemata(thd, table, db_name, From 95e99e12639f8cde87bba555dcb72cd8cc6542ad Mon Sep 17 00:00:00 2001 From: Praveenkumar Hulakund Date: Wed, 19 Mar 2014 12:30:30 +0530 Subject: [PATCH 06/25] Bug#11759519 - INFINITE HANG WITH 100% CPU USAGE WITH LOAD DATA LOCAL AND IMPORT ERRORS Description: ----------- This bug happens due to the fact that current algorithm is designed that in the case of LOCAL load of data, in case of the error, the remaining part of the file is read in order to return the proper error message to the client side. But, the problem with current implementation is that data stream for the client side is cleared only in the case where line delimiters exist, which is not a case with, for example fixed width fields. Fix: ---- Ported patch provided by Sinisa Milivojevic n bug report for this issue to 5.5+ versions. As part of this patch code is changed to clear the data stream by calling new member function "READ_INFO::skip_data_till_eof". --- mysql-test/r/loaddata.result | 12 ++++++++++++ mysql-test/t/loaddata.test | 21 +++++++++++++++++++++ sql/sql_load.cc | 19 +++++++++++++------ 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result index 932c1c76027..2d67d24bedd 100644 --- a/mysql-test/r/loaddata.result +++ b/mysql-test/r/loaddata.result @@ -520,3 +520,15 @@ LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug11735141.txt' INTO TABLE t1; ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field drop table t1; End of 5.1 tests +# +# Bug#11759519 INFINITE HANG WITH 100% CPU USAGE WITH LOAD DATA LOCAL AND IMPORT ERRORS +# +SET @old_mode= @@sql_mode; +CREATE TABLE t1 (fld1 INT); +SET sql_mode='strict_all_tables'; +# Without fix, load data hangs forever. +LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/mysql' REPLACE INTO TABLE t1 +FIELDS TERMINATED BY 't' LINES TERMINATED BY ''; +Got one of the listed errors +SET @@sql_mode= @old_mode; +DROP TABLE t1; diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index 80956aa2cb6..aa7be52484e 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -635,3 +635,24 @@ create table t1(a point); drop table t1; --echo End of 5.1 tests + +--echo # +--echo # Bug#11759519 INFINITE HANG WITH 100% CPU USAGE WITH LOAD DATA LOCAL AND IMPORT ERRORS +--echo # +SET @old_mode= @@sql_mode; +CREATE TABLE t1 (fld1 INT); +--copy_file $EXE_MYSQL $MYSQLTEST_VARDIR/mysql + +SET sql_mode='strict_all_tables'; + +--echo # Without fix, load data hangs forever. +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,1000 +eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/mysql' REPLACE INTO TABLE t1 + FIELDS TERMINATED BY 't' LINES TERMINATED BY ''; + +SET @@sql_mode= @old_mode; + +--remove_file $MYSQLTEST_VARDIR/mysql +DROP TABLE t1; + diff --git a/sql/sql_load.cc b/sql/sql_load.cc index b593412c559..7f962520dd6 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -56,6 +56,9 @@ XML_TAG::XML_TAG(int l, String f, String v) } +#define GET (stack_pos != stack ? *--stack_pos : my_b_get(&cache)) +#define PUSH(A) *(stack_pos++)=(A) + class READ_INFO { File file; uchar *buffer, /* Buffer for read text */ @@ -110,6 +113,15 @@ public: either the table or THD value */ void set_io_cache_arg(void* arg) { cache.arg = arg; } + + /** + skip all data till the eof. + */ + void skip_data_till_eof() + { + while (GET != my_b_EOF) + ; + } }; static int read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, @@ -534,8 +546,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, if (error) { if (read_file_from_client) - while (!read_info.next_line()) - ; + read_info.skip_data_till_eof(); #ifndef EMBEDDED_LIBRARY if (mysql_bin_log.is_open()) @@ -1392,10 +1403,6 @@ READ_INFO::~READ_INFO() } -#define GET (stack_pos != stack ? *--stack_pos : my_b_get(&cache)) -#define PUSH(A) *(stack_pos++)=(A) - - inline int READ_INFO::terminator(char *ptr,uint length) { int chr=0; // Keep gcc happy From 5541d7c656c449a9c97f4f8ed162046d696ea60f Mon Sep 17 00:00:00 2001 From: Thirunarayanan B Date: Tue, 1 Apr 2014 10:46:13 +0530 Subject: [PATCH 07/25] Bug #17858679 TOO MANY TIMES OF MEMSET DECREASE THE PERFORMANCE UNDER HEAVY INSERT Problem: There are three memset call to allocate memory for system fields in each insert. Solution: Instead of calling it in 3 times, we can combine it into one memset call. It will reduce the CPU usage under heavy insert. Approved by Marko rb-4916 --- storage/innobase/row/row0ins.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/storage/innobase/row/row0ins.c b/storage/innobase/row/row0ins.c index 9d5212db6e8..12c4f6dff8c 100644 --- a/storage/innobase/row/row0ins.c +++ b/storage/innobase/row/row0ins.c @@ -151,35 +151,37 @@ row_ins_alloc_sys_fields( ut_ad(row && table && heap); ut_ad(dtuple_get_n_fields(row) == dict_table_get_n_cols(table)); - /* 1. Allocate buffer for row id */ + /* allocate buffer to hold the needed system created hidden columns. */ + uint len = DATA_ROW_ID_LEN + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN; + ptr = mem_heap_zalloc(heap, len); + /* 1. Populate row-id */ col = dict_table_get_sys_col(table, DATA_ROW_ID); dfield = dtuple_get_nth_field(row, dict_col_get_no(col)); - ptr = mem_heap_zalloc(heap, DATA_ROW_ID_LEN); - dfield_set_data(dfield, ptr, DATA_ROW_ID_LEN); node->row_id_buf = ptr; - /* 3. Allocate buffer for trx id */ + ptr += DATA_ROW_ID_LEN; + /* 2. Populate trx id */ col = dict_table_get_sys_col(table, DATA_TRX_ID); dfield = dtuple_get_nth_field(row, dict_col_get_no(col)); - ptr = mem_heap_zalloc(heap, DATA_TRX_ID_LEN); dfield_set_data(dfield, ptr, DATA_TRX_ID_LEN); node->trx_id_buf = ptr; - /* 4. Allocate buffer for roll ptr */ + ptr += DATA_TRX_ID_LEN; + + /* 3. Populate roll ptr */ col = dict_table_get_sys_col(table, DATA_ROLL_PTR); dfield = dtuple_get_nth_field(row, dict_col_get_no(col)); - ptr = mem_heap_zalloc(heap, DATA_ROLL_PTR_LEN); dfield_set_data(dfield, ptr, DATA_ROLL_PTR_LEN); } From 0df90f2a6f58303fed6e9562963161c090677941 Mon Sep 17 00:00:00 2001 From: Thirunarayanan B Date: Tue, 1 Apr 2014 11:36:58 +0530 Subject: [PATCH 08/25] Bug #17858679 TOO MANY TIMES OF MEMSET DECREASE THE PERFORMANCE UNDER HEAVY INSERT Fixing the build problem in 5.5. --- storage/innobase/row/row0ins.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/innobase/row/row0ins.c b/storage/innobase/row/row0ins.c index 12c4f6dff8c..d9be81e461d 100644 --- a/storage/innobase/row/row0ins.c +++ b/storage/innobase/row/row0ins.c @@ -143,6 +143,7 @@ row_ins_alloc_sys_fields( const dict_col_t* col; dfield_t* dfield; byte* ptr; + uint len; row = node->row; table = node->table; @@ -152,7 +153,7 @@ row_ins_alloc_sys_fields( ut_ad(dtuple_get_n_fields(row) == dict_table_get_n_cols(table)); /* allocate buffer to hold the needed system created hidden columns. */ - uint len = DATA_ROW_ID_LEN + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN; + len = DATA_ROW_ID_LEN + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN; ptr = mem_heap_zalloc(heap, len); /* 1. Populate row-id */ From 4747ca1592a5a1c6359c7a086f30db631c1b36bd Mon Sep 17 00:00:00 2001 From: Balasubramanian Kandasamy Date: Thu, 3 Apr 2014 12:56:26 +0200 Subject: [PATCH 09/25] Support for enterprise packages --- packaging/rpm-oel/mysql.spec.in | 73 ++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 5 deletions(-) diff --git a/packaging/rpm-oel/mysql.spec.in b/packaging/rpm-oel/mysql.spec.in index d9e29317ff5..8744a4616aa 100644 --- a/packaging/rpm-oel/mysql.spec.in +++ b/packaging/rpm-oel/mysql.spec.in @@ -85,7 +85,7 @@ Name: mysql-%{product_suffix} Summary: A very fast and reliable SQL database server Group: Applications/Databases Version: @VERSION@ -Release: 4%{?dist} +Release: 5%{?commercial:.1}%{?dist} License: Copyright (c) 2000, @MYSQL_COPYRIGHT_YEAR@, %{mysql_vendor}. All rights reserved. Under %{?license_type} license as shown in the Description field. Source0: https://cdn.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/%{src_dir}.tar.gz URL: http://www.mysql.com/ @@ -153,13 +153,17 @@ Requires: procps Requires: shadow-utils Requires: net-tools %if 0%{?commercial} +Provides: MySQL-server-advanced%{?_isa} = %{version}-%{release} +Obsoletes: MySQL-server-advanced < %{version}-%{release} Obsoletes: mysql-community-server < %{version}-%{release} Requires: mysql-enterprise-client%{?_isa} = %{version}-%{release} Requires: mysql-enterprise-common%{?_isa} = %{version}-%{release} %else +Provides: MySQL-server%{?_isa} = %{version}-%{release} Requires: mysql-community-client%{?_isa} = %{version}-%{release} Requires: mysql-community-common%{?_isa} = %{version}-%{release} %endif +Obsoletes: MySQL-server < %{version}-%{release} Obsoletes: mysql-server < %{version}-%{release} Obsoletes: mariadb-server Provides: mysql-server = %{version}-%{release} @@ -199,11 +203,15 @@ to run and administer a MySQL server. Summary: MySQL database client applications and tools Group: Applications/Databases %if 0%{?commercial} +Provides: MySQL-client-advanced%{?_isa} = %{version}-%{release} +Obsoletes: MySQL-client-advanced < %{version}-%{release} Obsoletes: mysql-community-client < %{version}-%{release} Requires: mysql-enterprise-libs%{?_isa} = %{version}-%{release} %else +Provides: MySQL-client%{?_isa} = %{version}-%{release} Requires: mysql-community-libs%{?_isa} = %{version}-%{release} %endif +Obsoletes: MySQL-client < %{version}-%{release} Obsoletes: mariadb %if 0%{?rhel} > 5 Obsoletes: mysql < %{version}-%{release} @@ -234,11 +242,15 @@ MySQL database server, and MySQL embedded server. Summary: Test suite for the MySQL database server Group: Applications/Databases %if 0%{?commercial} +Provides: MySQL-test-advanced%{?_isa} = %{version}-%{release} +Obsoletes: MySQL-test-advanced < %{version}-%{release} Obsoletes: mysql-community-test < %{version}-%{release} Requires: mysql-enterprise-server%{?_isa} = %{version}-%{release} %else +Provides: MySQL-test%{?_isa} = %{version}-%{release} Requires: mysql-community-server%{?_isa} = %{version}-%{release} %endif +Obsoletes: MySQL-test < %{version}-%{release} Obsoletes: mysql-test < %{version}-%{release} Obsoletes: mariadb-test Provides: mysql-test = %{version}-%{release} @@ -254,11 +266,15 @@ database server. Summary: Development header files and libraries for MySQL database client applications Group: Applications/Databases %if 0%{?commercial} +Provides: MySQL-devel-advanced%{?_isa} = %{version}-%{release} +Obsoletes: MySQL-devel-advanced < %{version}-%{release} Obsoletes: mysql-community-devel < %{version}-%{release} Requires: mysql-enterprise-libs%{?_isa} = %{version}-%{release} %else +Provides: MySQL-devel%{?_isa} = %{version}-%{release} Requires: mysql-community-libs%{?_isa} = %{version}-%{release} %endif +Obsoletes: MySQL-devel < %{version}-%{release} Obsoletes: mysql-devel < %{version}-%{release} Obsoletes: mariadb-devel Provides: mysql-devel = %{version}-%{release} @@ -272,11 +288,15 @@ to develop MySQL client applications. Summary: Shared libraries for MySQL database client applications Group: Applications/Databases %if 0%{?commercial} +Provides: MySQL-shared-advanced%{?_isa} = %{version}-%{release} +Obsoletes: MySQL-shared-advanced < %{version}-%{release} Obsoletes: mysql-community-libs < %{version}-%{release} Requires: mysql-enterprise-common%{?_isa} = %{version}-%{release} %else +Provides: MySQL-shared%{?_isa} = %{version}-%{release} Requires: mysql-community-common%{?_isa} = %{version}-%{release} %endif +Obsoletes: MySQL-shared < %{version}-%{release} Obsoletes: mysql-libs < %{version}-%{release} Obsoletes: mariadb-libs Provides: mysql-libs = %{version}-%{release} @@ -294,11 +314,15 @@ Obsoletes: mysql-libs-compat < %{version}-%{release} Provides: mysql-libs-compat = %{version}-%{release} Provides: mysql-libs-compat%{?_isa} = %{version}-%{release} %if 0%{?commercial} +Provides: MySQL-shared-compat-advanced%{?_isa} = %{version}-%{release} +Obsoletes: MySQL-shared-compat-advanced < %{version}-%{release} Obsoletes: mysql-community-libs-compat < %{version}-%{release} Requires: mysql-enterprise-libs%{?_isa} = %{version}-%{release} %else +Provides: MySQL-shared-compat%{?_isa} = %{version}-%{release} Requires: mysql-community-libs%{?_isa} = %{version}-%{release} %endif +Obsoletes: MySQL-shared-compat < %{version}-%{release} %if 0%{?rhel} > 5 Obsoletes: mysql-libs < %{version}-%{release} %endif @@ -312,11 +336,15 @@ applications. Summary: MySQL embedded library Group: Applications/Databases %if 0%{?commercial} +Provides: MySQL-embedded-advanced%{?_isa} = %{version}-%{release} +Obsoletes: MySQL-embedded-advanced < %{version}-%{release} Obsoletes: mysql-community-embedded < %{version}-%{release} Requires: mysql-enterprise-common%{?_isa} = %{version}-%{release} %else +Provides: MySQL-embedded%{?_isa} = %{version}-%{release} Requires: mysql-community-common%{?_isa} = %{version}-%{release} %endif +Obsoletes: MySQL-embedded < %{version}-%{release} Obsoletes: mysql-embedded < %{version}-%{release} Provides: mysql-embedded = %{version}-%{release} Provides: mysql-emdedded%{?_isa} = %{version}-%{release} @@ -435,9 +463,6 @@ popd ) %endif # 0%{?compatlib} -export CFLAGS="%{optflags} %{?el7:-DTAOCRYPT_DISABLE_X86ASM}" -export CXXFLAGS="%{optflags} %{?el7:-DTAOCRYPT_DISABLE_X86ASM}" - # Build debug versions of mysqld and libmysqld.a mkdir debug ( @@ -676,7 +701,41 @@ fi %attr(755, root, root) %{_sbindir}/mysqld %attr(755, root, root) %{_sbindir}/mysqld-debug -%{_libdir}/mysql/plugin +%dir %{_libdir}/mysql/plugin +%attr(755, root, root) %{_libdir}/mysql/plugin/adt_null.so +%attr(755, root, root) %{_libdir}/mysql/plugin/auth_socket.so +%attr(755, root, root) %{_libdir}/mysql/plugin/mypluglib.so +%attr(755, root, root) %{_libdir}/mysql/plugin/semisync_master.so +%attr(755, root, root) %{_libdir}/mysql/plugin/semisync_slave.so +%dir %{_libdir}/mysql/plugin/debug +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/adt_null.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/auth_socket.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/mypluglib.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/semisync_master.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/semisync_slave.so + +%attr(755, root, root) %{_libdir}/mysql/plugin/auth.so +%attr(755, root, root) %{_libdir}/mysql/plugin/auth_test_plugin.so +%attr(644, root, root) %{_libdir}/mysql/plugin/daemon_example.ini +%attr(755, root, root) %{_libdir}/mysql/plugin/libdaemon_example.so +%attr(755, root, root) %{_libdir}/mysql/plugin/qa_auth_client.so +%attr(755, root, root) %{_libdir}/mysql/plugin/qa_auth_interface.so +%attr(755, root, root) %{_libdir}/mysql/plugin/qa_auth_server.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/auth.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/auth_test_plugin.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/libdaemon_example.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/qa_auth_client.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/qa_auth_interface.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/qa_auth_server.so + +%if 0%{?commercial} +%attr(755, root, root) %{_libdir}/mysql/plugin/audit_log.so +%attr(755, root, root) %{_libdir}/mysql/plugin/authentication_pam.so +%attr(755, root, root) %{_libdir}/mysql/plugin/thread_pool.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/audit_log.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/authentication_pam.so +%attr(755, root, root) %{_libdir}/mysql/plugin/debug/thread_pool.so +%endif %attr(644, root, root) %{_datadir}/mysql/fill_help_tables.sql %attr(644, root, root) %{_datadir}/mysql/mysql_system_tables.sql @@ -819,6 +878,10 @@ fi %endif %changelog +* Mon Mar 31 2014 Balasubramanian Kandasamy - 5.5.37-5 +- Support for enterprise packages +- Upgrade from MySQL-* packages + * Fri Mar 14 2014 Balasubramanian Kandasamy - 5.5.37-4 - Resolve mysql conflict with mysql-community-client From 1a9ce19c116154457dd35ebcaf1eb6ee7e74a891 Mon Sep 17 00:00:00 2001 From: Balasubramanian Kandasamy Date: Fri, 4 Apr 2014 05:58:49 +0200 Subject: [PATCH 10/25] Changed permisison for filter-requires.sh and filter-provides.sh --- packaging/rpm-oel/filter-provides.sh | 0 packaging/rpm-oel/filter-requires.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 packaging/rpm-oel/filter-provides.sh mode change 100644 => 100755 packaging/rpm-oel/filter-requires.sh diff --git a/packaging/rpm-oel/filter-provides.sh b/packaging/rpm-oel/filter-provides.sh old mode 100644 new mode 100755 diff --git a/packaging/rpm-oel/filter-requires.sh b/packaging/rpm-oel/filter-requires.sh old mode 100644 new mode 100755 From 7f8fb4509e9dbd7314f899284349556d0b354083 Mon Sep 17 00:00:00 2001 From: Serge Kozlov Date: Fri, 4 Apr 2014 10:42:25 +0400 Subject: [PATCH 11/25] BUG#18506556. Added sync slave with master for clean-up --- mysql-test/suite/rpl/t/rpl_heartbeat_basic.test | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test b/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test index 78489449ab8..87939aa3c65 100644 --- a/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test +++ b/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test @@ -363,13 +363,11 @@ let $result= query_get_value(SELECT ($rcvd_heartbeats_after - $rcvd_heartbeats_b --connection master DELETE FROM t1; DROP EVENT e1; +--sync_slave_with_master --echo - - # Check received heartbeat events while logs flushed on slave ---connection slave --echo *** Flush logs on slave *** STOP SLAVE; RESET SLAVE; From b2e66814b4ba860f464c9217c5f8c45fb254a089 Mon Sep 17 00:00:00 2001 From: Balasubramanian Kandasamy Date: Mon, 7 Apr 2014 14:51:44 +0200 Subject: [PATCH 12/25] Fix Cflags for el7 --- packaging/rpm-oel/mysql.spec.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packaging/rpm-oel/mysql.spec.in b/packaging/rpm-oel/mysql.spec.in index 8744a4616aa..2dc71b4c40d 100644 --- a/packaging/rpm-oel/mysql.spec.in +++ b/packaging/rpm-oel/mysql.spec.in @@ -85,7 +85,7 @@ Name: mysql-%{product_suffix} Summary: A very fast and reliable SQL database server Group: Applications/Databases Version: @VERSION@ -Release: 5%{?commercial:.1}%{?dist} +Release: 6%{?commercial:.1}%{?dist} License: Copyright (c) 2000, @MYSQL_COPYRIGHT_YEAR@, %{mysql_vendor}. All rights reserved. Under %{?license_type} license as shown in the Description field. Source0: https://cdn.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/%{src_dir}.tar.gz URL: http://www.mysql.com/ @@ -495,6 +495,8 @@ mkdir release -DBUILD_CONFIG=mysql_release \ -DINSTALL_LAYOUT=RPM \ -DCMAKE_BUILD_TYPE=RelWithDebInfo %{?el7:-DENABLE_DTRACE=OFF} \ + -DCMAKE_C_FLAGS="%{optflags}" \ + -DCMAKE_CXX_FLAGS="%{optflags}" \ -DINSTALL_LIBDIR="%{_lib}/mysql" \ -DINSTALL_PLUGINDIR="%{_lib}/mysql/plugin" \ -DMYSQL_UNIX_ADDR="%{mysqldatadir}/mysql.sock" \ @@ -878,6 +880,9 @@ fi %endif %changelog +* Mon Apr 07 2014 Balasubramanian Kandasamy - 5.5.37-6 +- Fix Cflags for el7 + * Mon Mar 31 2014 Balasubramanian Kandasamy - 5.5.37-5 - Support for enterprise packages - Upgrade from MySQL-* packages From c5f8d2587a3e3a38ebe62b08e4cada0e8f84ee4d Mon Sep 17 00:00:00 2001 From: Balasubramanian Kandasamy Date: Mon, 7 Apr 2014 16:36:09 +0200 Subject: [PATCH 13/25] updated optflags variable and cmake option for debug build --- packaging/rpm-oel/mysql.spec.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packaging/rpm-oel/mysql.spec.in b/packaging/rpm-oel/mysql.spec.in index 2dc71b4c40d..44b387bbebf 100644 --- a/packaging/rpm-oel/mysql.spec.in +++ b/packaging/rpm-oel/mysql.spec.in @@ -468,12 +468,13 @@ mkdir debug ( cd debug # Attempt to remove any optimisation flags from the debug build - CFLAGS=$(echo "${CFLAGS}" | sed -e 's/-O2 / /' -e 's/-Wp,-D_FORTIFY_SOURCE=2/ /') - CXXFLAGS=$(echo "${CFLAGS}" | sed -e 's/-O2 / /' -e 's/-Wp,-D_FORTIFY_SOURCE=2/ /') + optflags=$(echo "%{optflags}" | sed -e 's/-O2 / /' -e 's/-Wp,-D_FORTIFY_SOURCE=2/ /') cmake ../%{src_dir} \ -DBUILD_CONFIG=mysql_release \ -DINSTALL_LAYOUT=RPM \ -DCMAKE_BUILD_TYPE=Debug %{?el7:-DENABLE_DTRACE=OFF} \ + -DCMAKE_C_FLAGS="$optflags" \ + -DCMAKE_CXX_FLAGS="$optflags" \ -DINSTALL_LIBDIR="%{_lib}/mysql" \ -DINSTALL_PLUGINDIR="%{_lib}/mysql/plugin" \ -DMYSQL_UNIX_ADDR="%{mysqldatadir}/mysql.sock" \ From 92351c831f7fefcbbd48c7e914225fdc55adad36 Mon Sep 17 00:00:00 2001 From: Arun Kuruvila Date: Thu, 10 Apr 2014 11:10:31 +0530 Subject: [PATCH 14/25] Description: When we execute a correlated subquery on an archive table which is using an auto increment column, the server hangs. In order to recover the mysqld process, it has to be terminated abnormally using SIGKILL. The problem is observed in mysql-5.5. Bug #18065452 "PREPARING" STATE HOGS CPU WITH ARCHIVE + SUBQUERY Analysis: This happens because the server is trapped inside an infinite loop in the function, "subselect_indexsubquery_engine::exec()". This function resolves the correlated suquery by doing an index lookup for the appropriate engine. In case of archive engine, after reaching the end of records, "table->status" is not set to STATUS_NOT_FOUND. As a result the loop is not terminated. Fix: The "table->status" is set to STATUS_NOT_FOUND when the end of records is reached. --- storage/archive/ha_archive.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 164c59f2426..aafbedf6a07 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -1,5 +1,6 @@ /* - Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2004, 2014, 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 @@ -1078,6 +1079,7 @@ int ha_archive::index_next(uchar * buf) } rc= found ? 0 : HA_ERR_END_OF_FILE; + table->status= rc ? STATUS_NOT_FOUND : 0; MYSQL_INDEX_READ_ROW_DONE(rc); DBUG_RETURN(rc); } From 37b9a31a3095dd8f4a15b957f1c4b28fe4fab4ed Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Thu, 10 Apr 2014 13:18:32 +0300 Subject: [PATCH 15/25] Bug #18359924: INNODB AND MYISAM CORRUPTION ON PREFIX INDEXES The problem was in the validation of the input data for blob types. When assigned binary data, the character blob types were only checking if the length of these data is a multiple of the minimum char length for the destination charset. And since e.g. UTF-8's minimum character length is 1 (becuase it's variable length) even byte sequences that are invalid utf-8 strings (e.g. wrong leading byte etc) were copied verbatim into utf-8 columns when coming from binary strings or fields. Storing invalid data into string columns was having all kinds of ill effects on code that assumed that the encoding data are valid to begin with. Fixed by additionally checking the incoming binary string for validity when assigning it to a non-binary string column. Made sure the conversions to charsets with no known "invalid" ranges are not covered by the extra check. Removed trailing spaces. Test case added. --- sql/field.cc | 8 +++----- sql/sql_string.cc | 30 ++++++++++++++++++++++++++++++ sql/sql_string.h | 3 +++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index c65346423a0..3069a1ef60b 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -7376,8 +7376,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) If content of the 'from'-address is cached in the 'value'-object it is possible that the content needs a character conversion. */ - uint32 dummy_offset; - if (!String::needs_conversion(length, cs, field_charset, &dummy_offset)) + if (!String::needs_conversion_on_storage(length, cs, field_charset)) { Field_blob::store_length(length); bmove(ptr+packlength, &from, sizeof(char*)); @@ -7980,7 +7979,7 @@ int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs) String tmpstr(buff,sizeof(buff), &my_charset_bin); /* Convert character set if necessary */ - if (String::needs_conversion(length, cs, field_charset, ¬_used)) + if (String::needs_conversion_on_storage(length, cs, field_charset)) { uint dummy_errors; tmpstr.copy(from, length, cs, field_charset, &dummy_errors); @@ -8196,12 +8195,11 @@ int Field_set::store(const char *from,uint length,CHARSET_INFO *cs) int err= 0; char *not_used; uint not_used2; - uint32 not_used_offset; char buff[STRING_BUFFER_USUAL_SIZE]; String tmpstr(buff,sizeof(buff), &my_charset_bin); /* Convert character set if necessary */ - if (String::needs_conversion(length, cs, field_charset, ¬_used_offset)) + if (String::needs_conversion_on_storage(length, cs, field_charset)) { uint dummy_errors; tmpstr.copy(from, length, cs, field_charset, &dummy_errors); diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 07fc7e4ff1d..b9a9ce92cd6 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -223,6 +223,36 @@ bool String::needs_conversion(uint32 arg_length, } +/* + Checks that the source string can just be copied to the destination string + without conversion. + Unlike needs_conversion it will require conversion on incoming binary data + to ensure the data are verified for vailidity first. + + @param arg_length Length of string to copy. + @param from_cs Character set to copy from + @param to_cs Character set to copy to + + @return conversion needed +*/ +bool String::needs_conversion_on_storage(uint32 arg_length, + CHARSET_INFO *cs_from, + CHARSET_INFO *cs_to) +{ + uint32 offset; + return (needs_conversion(arg_length, cs_from, cs_to, &offset) || + (cs_from == &my_charset_bin && /* force conversion when storing a binary string */ + cs_to != &my_charset_bin && /* into a non-binary destination */ + ( /* and any of the following is true :*/ + cs_to->mbminlen != cs_to->mbmaxlen || /* it's a variable length encoding */ + cs_to->mbminlen > 2 || /* longer than 2 bytes : neither 1 byte nor ucs2 */ + 0 != (arg_length % cs_to->mbmaxlen) + ) + ) + ); +} + + /* Copy a multi-byte character sets with adding leading zeros. diff --git a/sql/sql_string.h b/sql/sql_string.h index 234e8272b88..971af9ea91a 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -280,6 +280,9 @@ public: static bool needs_conversion(uint32 arg_length, CHARSET_INFO *cs_from, CHARSET_INFO *cs_to, uint32 *offset); + static bool needs_conversion_on_storage(uint32 arg_length, + CHARSET_INFO *cs_from, + CHARSET_INFO *cs_to); bool copy_aligned(const char *s, uint32 arg_length, uint32 offset, CHARSET_INFO *cs); bool set_or_copy_aligned(const char *s, uint32 arg_length, CHARSET_INFO *cs); From ea38c2658229c45e48bf417168efc85f4768cef4 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 11 Apr 2014 10:42:30 +0300 Subject: [PATCH 16/25] Addendum #1 to the fix for bug #18359924 Removed unused variable. Fixed long (>80 lines) --- sql/field.cc | 1 - sql/sql_string.cc | 16 +++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index 3069a1ef60b..abe856a8292 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -7974,7 +7974,6 @@ int Field_enum::store(const char *from,uint length,CHARSET_INFO *cs) { ASSERT_COLUMN_MARKED_FOR_WRITE; int err= 0; - uint32 not_used; char buff[STRING_BUFFER_USUAL_SIZE]; String tmpstr(buff,sizeof(buff), &my_charset_bin); diff --git a/sql/sql_string.cc b/sql/sql_string.cc index b9a9ce92cd6..41725128415 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -241,11 +241,17 @@ bool String::needs_conversion_on_storage(uint32 arg_length, { uint32 offset; return (needs_conversion(arg_length, cs_from, cs_to, &offset) || - (cs_from == &my_charset_bin && /* force conversion when storing a binary string */ - cs_to != &my_charset_bin && /* into a non-binary destination */ - ( /* and any of the following is true :*/ - cs_to->mbminlen != cs_to->mbmaxlen || /* it's a variable length encoding */ - cs_to->mbminlen > 2 || /* longer than 2 bytes : neither 1 byte nor ucs2 */ + /* force conversion when storing a binary string */ + (cs_from == &my_charset_bin && + /* into a non-binary destination */ + cs_to != &my_charset_bin && + /* and any of the following is true :*/ + ( + /* it's a variable length encoding */ + cs_to->mbminlen != cs_to->mbmaxlen || + /* longer than 2 bytes : neither 1 byte nor ucs2 */ + cs_to->mbminlen > 2 || + /* and is not a multiple of the char byte size */ 0 != (arg_length % cs_to->mbmaxlen) ) ) From 1b74f2e3da53dd8b965920fad2ff599df2d1fc89 Mon Sep 17 00:00:00 2001 From: Sujatha Sivakumar Date: Tue, 15 Apr 2014 15:17:25 +0530 Subject: [PATCH 17/25] Bug#17942050:KILL OF TRUNCATE TABLE WILL LEAD TO BINARY LOG WRITTEN WHILE ROWS REMAINS Problem: ======== When truncate table fails while using transactional based engines even though the operation errors out we still continue and log it to binlog. Because of this master has data but the truncate will be written to binary log which will cause inconsistency. Analysis: ======== Truncate table can happen either through drop and create of table or by deleting rows. In the second case the existing code is written in such a way that even if an error occurs the truncate statement will always be binlogged. Which is not correct. Binlogging of TRUNCATE TABLE statement should check whether truncate is executed "transactionally or not". If the table is transaction based we log the TRUNCATE TABLE only on successful completion. If table is non transactional there are possibilities that on error we could have partial changes done hence in such cases we do log in spite of errors as some of the lines might have been removed, so the statement has to be sent to slave. Fix: === Using table handler whether truncate table is being executed in transaction based mode or not is identified and statement is binlogged accordingly. mysql-test/suite/binlog/r/binlog_truncate_kill.result: Added test case to test the fix for Bug#17942050. mysql-test/suite/binlog/t/binlog_truncate_kill.test: Added test case to test the fix for Bug#17942050. sql/sql_truncate.cc: Check if truncation is successful or not and retun appropriate return values so that binlogging can be done based on that. sql/sql_truncate.h: Added a new enum. --- .../binlog/r/binlog_truncate_kill.result | 33 +++++++++++ .../suite/binlog/t/binlog_truncate_kill.test | 56 +++++++++++++++++++ sql/sql_truncate.cc | 51 ++++++++++++----- sql/sql_truncate.h | 10 +++- 4 files changed, 135 insertions(+), 15 deletions(-) create mode 100644 mysql-test/suite/binlog/r/binlog_truncate_kill.result create mode 100644 mysql-test/suite/binlog/t/binlog_truncate_kill.test diff --git a/mysql-test/suite/binlog/r/binlog_truncate_kill.result b/mysql-test/suite/binlog/r/binlog_truncate_kill.result new file mode 100644 index 00000000000..c2ea2e8d404 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_truncate_kill.result @@ -0,0 +1,33 @@ +RESET MASTER; +connection default; +CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, a INT, b INT) ENGINE=INNODB; +INSERT INTO t1(a, b) VALUES(1,2),(2,4),(3,6),(4,8),(5,10); +SET DEBUG_SYNC = "open_and_process_table signal truncate_before_lock wait_for forever"; +TRUNCATE t1; +connect con1,localhost,root,,; +SET DEBUG_SYNC = "now wait_for truncate_before_lock"; +SELECT ((@id := id) - id) FROM information_schema.processlist WHERE processlist.info LIKE '%TRUNCATE t1%' AND state LIKE '%open_and_process_table%'; +((@id := id) - id) +0 +KILL QUERY @id; +connection default; +ERROR 70100: Query execution was interrupted +connection con1; +show binlog events from ; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Query # # use `test`; CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, a INT, b INT) ENGINE=INNODB +master-bin.000001 # Query # # BEGIN +master-bin.000001 # Intvar # # INSERT_ID=1 +master-bin.000001 # Query # # use `test`; INSERT INTO t1(a, b) VALUES(1,2),(2,4),(3,6),(4,8),(5,10) +master-bin.000001 # Xid # # COMMIT /* XID */ +disconnect con1; +connection default; +SELECT * FROM t1; +id a b +1 1 2 +2 2 4 +3 3 6 +4 4 8 +5 5 10 +DROP TABLE t1; +SET DEBUG_SYNC= 'RESET'; diff --git a/mysql-test/suite/binlog/t/binlog_truncate_kill.test b/mysql-test/suite/binlog/t/binlog_truncate_kill.test new file mode 100644 index 00000000000..ffbccfa536f --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_truncate_kill.test @@ -0,0 +1,56 @@ +############################################################################### +# Bug#17942050:KILL OF TRUNCATE TABLE WILL LEAD TO BINARY LOG WRITTEN WHILE +# ROWS REMAINS +# +# Problem: +# ======== +# When truncate table fails while using transactional based engines even +# though the operation errors out we still continue and log it to binlog. +# Because of this master has data but the truncate will be written to binary +# log which will cause inconsistency. +# +# Test: +# ===== +# Make master to wait in "open_table" call during the execution of truncate +# table command and kill the truncate table from other connection. This causes +# open table to return an error saying truncate failed during open table. This +# statement should not be binlogged. +############################################################################### +--source include/have_debug_sync.inc +--source include/have_binlog_format_statement.inc +RESET MASTER; +--enable_connect_log +--connection default +CREATE TABLE t1(id INT AUTO_INCREMENT PRIMARY KEY, a INT, b INT) ENGINE=INNODB; +INSERT INTO t1(a, b) VALUES(1,2),(2,4),(3,6),(4,8),(5,10); +SET DEBUG_SYNC = "open_and_process_table signal truncate_before_lock wait_for forever"; +--send TRUNCATE t1 + +connect(con1,localhost,root,,); +SET DEBUG_SYNC = "now wait_for truncate_before_lock"; +# Wait for one connection to reach open_and_process_table. +--let $show_statement= SHOW PROCESSLIST +--let $field= State +--let $condition= 'debug sync point: open_and_process_table'; +--source include/wait_show_condition.inc + +SELECT ((@id := id) - id) FROM information_schema.processlist WHERE processlist.info LIKE '%TRUNCATE t1%' AND state LIKE '%open_and_process_table%'; +# Test killing from mysql server +KILL QUERY @id; + +connection default; +--ERROR ER_QUERY_INTERRUPTED +--reap + +connection con1; +--source include/show_binlog_events.inc + +disconnect con1; +--source include/wait_until_disconnected.inc +connection default; + +SELECT * FROM t1; + +DROP TABLE t1; +SET DEBUG_SYNC= 'RESET'; +--disable_connect_log diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index 2285131fade..07bf145c847 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2014, 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 @@ -181,12 +181,19 @@ fk_truncate_illegal_if_parent(THD *thd, TABLE *table) @param table_ref Table list element for the table to be truncated. @param is_tmp_table True if element refers to a temp table. - @retval 0 Success. - @retval > 0 Error code. + @retval TRUNCATE_OK Truncate was successful and statement can be safely + binlogged. + @retval TRUNCATE_FAILED_BUT_BINLOG Truncate failed but still go ahead with + binlogging as in case of non transactional tables + partial truncation is possible. + + @retval TRUNCATE_FAILED_SKIP_BINLOG Truncate was not successful hence donot + binlong the statement. */ -int Truncate_statement::handler_truncate(THD *thd, TABLE_LIST *table_ref, - bool is_tmp_table) +enum Truncate_statement::truncate_result +Truncate_statement::handler_truncate(THD *thd, TABLE_LIST *table_ref, + bool is_tmp_table) { int error= 0; uint flags; @@ -228,16 +235,30 @@ int Truncate_statement::handler_truncate(THD *thd, TABLE_LIST *table_ref, /* Open the table as it will handle some required preparations. */ if (open_and_lock_tables(thd, table_ref, FALSE, flags)) - DBUG_RETURN(1); + DBUG_RETURN(TRUNCATE_FAILED_SKIP_BINLOG); /* Whether to truncate regardless of foreign keys. */ if (! (thd->variables.option_bits & OPTION_NO_FOREIGN_KEY_CHECKS)) - error= fk_truncate_illegal_if_parent(thd, table_ref->table); + if (fk_truncate_illegal_if_parent(thd, table_ref->table)) + DBUG_RETURN(TRUNCATE_FAILED_SKIP_BINLOG); - if (!error && (error= table_ref->table->file->ha_truncate())) + error= table_ref->table->file->ha_truncate(); + if (error) + { table_ref->table->file->print_error(error, MYF(0)); - - DBUG_RETURN(error); + /* + If truncate method is not implemented then we don't binlog the + statement. If truncation has failed in a transactional engine then also we + donot binlog the statment. Only in non transactional engine we binlog + inspite of errors. + */ + if (error == HA_ERR_WRONG_COMMAND || + table_ref->table->file->has_transactions()) + DBUG_RETURN(TRUNCATE_FAILED_SKIP_BINLOG); + else + DBUG_RETURN(TRUNCATE_FAILED_BUT_BINLOG); + } + DBUG_RETURN(TRUNCATE_OK); } @@ -470,10 +491,14 @@ bool Truncate_statement::truncate_table(THD *thd, TABLE_LIST *table_ref) /* All effects of a TRUNCATE TABLE operation are committed even if - truncation fails. Thus, the query must be written to the binary - log. The only exception is a unimplemented truncate method. + truncation fails in the case of non transactional tables. Thus, the + query must be written to the binary log. The only exception is a + unimplemented truncate method. */ - binlog_stmt= !error || error != HA_ERR_WRONG_COMMAND; + if (error == TRUNCATE_OK || error == TRUNCATE_FAILED_BUT_BINLOG) + binlog_stmt= true; + else + binlog_stmt= false; } /* diff --git a/sql/sql_truncate.h b/sql/sql_truncate.h index 95a2f35df4f..0280ecc4932 100644 --- a/sql/sql_truncate.h +++ b/sql/sql_truncate.h @@ -1,6 +1,6 @@ #ifndef SQL_TRUNCATE_INCLUDED #define SQL_TRUNCATE_INCLUDED -/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2014, 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 @@ -47,11 +47,17 @@ public: bool execute(THD *thd); protected: + enum truncate_result{ + TRUNCATE_OK=0, + TRUNCATE_FAILED_BUT_BINLOG, + TRUNCATE_FAILED_SKIP_BINLOG + }; + /** Handle locking a base table for truncate. */ bool lock_table(THD *, TABLE_LIST *, bool *); /** Truncate table via the handler method. */ - int handler_truncate(THD *, TABLE_LIST *, bool); + enum truncate_result handler_truncate(THD *, TABLE_LIST *, bool); /** Optimized delete of all rows by doing a full regenerate of the table. From 22e9aa1c1a9607e56620be93728479331ab90ed5 Mon Sep 17 00:00:00 2001 From: Igor Solodovnikov Date: Thu, 17 Apr 2014 16:33:55 +0300 Subject: [PATCH 18/25] Bug #18053212 MYSQL_GET_SERVER_VERSION() CALL WITHOUT A VALID CONNECTION RESULTS IN SEG FAULT When there is no connection mysql_get_server_version() will return 0 and report CR_COMMANDS_OUT_OF_SYNC error. --- sql-common/client.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/sql-common/client.c b/sql-common/client.c index 16a61d7f53d..f2c091261b4 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -4230,17 +4230,27 @@ const char * STDCALL mysql_error(MYSQL *mysql) RETURN Signed number > 323000 + Zero if there is no connection */ ulong STDCALL mysql_get_server_version(MYSQL *mysql) { - uint major, minor, version; - char *pos= mysql->server_version, *end_pos; - major= (uint) strtoul(pos, &end_pos, 10); pos=end_pos+1; - minor= (uint) strtoul(pos, &end_pos, 10); pos=end_pos+1; - version= (uint) strtoul(pos, &end_pos, 10); - return (ulong) major*10000L+(ulong) (minor*100+version); + ulong major= 0, minor= 0, version= 0; + + if (mysql->server_version) + { + char *pos= mysql->server_version, *end_pos; + major= strtoul(pos, &end_pos, 10); pos=end_pos+1; + minor= strtoul(pos, &end_pos, 10); pos=end_pos+1; + version= strtoul(pos, &end_pos, 10); + } + else + { + set_mysql_error(mysql, CR_COMMANDS_OUT_OF_SYNC, unknown_sqlstate); + } + + return major*10000 + minor*100 + version; } From 3d73cd23d0e337560b8c044c728af3cf8a192b62 Mon Sep 17 00:00:00 2001 From: Igor Solodovnikov Date: Wed, 23 Apr 2014 12:46:00 +0300 Subject: [PATCH 19/25] Bug #17514920 MYSQL_THREAD_INIT() CALL WITHOUT MYSQL_INIT() IS CRASHING IN WINDOWS It is error to call mysql_thread_init() before libmysql is initialized with mysql_library_init(). Thus to fix this bug we need to detect if library was initialized and return error result if mysql_thread_init() is called with uninitialized library. Fixed by checking my_thread_global_init_done and returning nonzero if the library is not initialized. --- mysys/my_thr_init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index d213b67377b..5d1376ea3ce 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -313,6 +313,9 @@ my_bool my_thread_init(void) struct st_my_thread_var *tmp; my_bool error=0; + if (!my_thread_global_init_done) + return 1; /* cannot proceed with unintialized library */ + #ifdef EXTRA_DEBUG_THREADS fprintf(stderr,"my_thread_init(): thread_id: 0x%lx\n", (ulong) pthread_self()); From c76e29c88415fbb381893f70cd7a9865cd49ee25 Mon Sep 17 00:00:00 2001 From: Tor Didriksen Date: Wed, 23 Apr 2014 17:01:35 +0200 Subject: [PATCH 20/25] Backport from trunk: Bug#18396916 MAIN.OUTFILE_LOADDATA TEST FAILS ON ARM, AARCH64, PPC/PPC64 The recorded results for the failing tests were wrong. They were introduced by the patch for Bug#30946 mysqldump silently ignores --default-character-set when used with --tab Correct results were returned for platforms where 'char' is implemented as unsigned. This was reported as Bug#46895 Test "outfile_loaddata" fails (reproducible) Bug#11755168 46895: TEST "OUTFILE_LOADDATA" FAILS (REPRODUCIBLE) The patch for that bug fixed only parts of the problem, leaving the incorrect results in the .result file. Solution: use 'uchar' for field_terminator and line_terminator on all platforms. Also: remove some un-necessary casts, leaving the ones we actually need. --- mysql-test/r/outfile_loaddata.result | 24 ++++++++----- mysql-test/t/outfile_loaddata.test | 4 +++ sql/sql_load.cc | 53 ++++++++++++++++------------ 3 files changed, 51 insertions(+), 30 deletions(-) diff --git a/mysql-test/r/outfile_loaddata.result b/mysql-test/r/outfile_loaddata.result index 36a72fd84ce..ca3a42c087c 100644 --- a/mysql-test/r/outfile_loaddata.result +++ b/mysql-test/r/outfile_loaddata.result @@ -143,15 +143,16 @@ TRUNCATE t2; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/t1.txt' INTO TABLE t2 CHARACTER SET binary FIELDS TERMINATED BY 'ъ'; Warnings: Warning 1638 Non-ASCII separator arguments are not fully supported -Warning 1265 Data truncated for column 'a' at row 1 -Warning 1261 Row 1 doesn't contain data for all columns -Warning 1261 Row 1 doesn't contain data for all columns -Warning 1265 Data truncated for column 'a' at row 2 -Warning 1261 Row 2 doesn't contain data for all columns -Warning 1261 Row 2 doesn't contain data for all columns SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; a b c -1 NULL NULL +1 ABC-АБВ DEF-ÂÃÄ +2 NULL NULL +SELECT * FROM t1; +a b c +1 ABC-АБВ DEF-ÂÃÄ +2 NULL NULL +SELECT * FROM t2; +a b c 1 ABC-АБВ DEF-ÂÃÄ 2 NULL NULL SELECT * FROM t1 INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/t1.txt' LINES STARTING BY 'ъ'; @@ -181,7 +182,14 @@ Warning 1638 Non-ASCII separator arguments are not fully supported SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; a b c 1 ABC-АБВ DEF-ÂÃÄ -1 ABC-АБВ DEF-ÂÃÄÑŠ2 +2 NULL NULL +SELECT * FROM t1; +a b c +1 ABC-АБВ DEF-ÂÃÄ +2 NULL NULL +SELECT * FROM t2; +a b c +1 ABC-АБВ DEF-ÂÃÄ 2 NULL NULL # Default (binary) charset: SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/t1.txt' FROM t1; diff --git a/mysql-test/t/outfile_loaddata.test b/mysql-test/t/outfile_loaddata.test index 26760f9a1b2..745c75cb4de 100644 --- a/mysql-test/t/outfile_loaddata.test +++ b/mysql-test/t/outfile_loaddata.test @@ -169,6 +169,8 @@ TRUNCATE t2; --eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary FIELDS TERMINATED BY 'ъ' --remove_file $file SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; +SELECT * FROM t1; +SELECT * FROM t2; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --eval SELECT * FROM t1 INTO OUTFILE '$file' LINES STARTING BY 'ъ' @@ -191,6 +193,8 @@ TRUNCATE t2; --eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary LINES TERMINATED BY 'ъ' --remove_file $file SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; +SELECT * FROM t1; +SELECT * FROM t2; --echo # Default (binary) charset: diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 7f962520dd6..05571d49cc8 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2014, 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 @@ -65,7 +65,8 @@ class READ_INFO { *end_of_buff; /* Data in bufferts ends here */ uint buff_length, /* Length of buffert */ max_length; /* Max length of row */ - char *field_term_ptr,*line_term_ptr,*line_start_ptr,*line_start_end; + const uchar *field_term_ptr,*line_term_ptr; + const char *line_start_ptr,*line_start_end; uint field_term_length,line_term_length,enclosed_length; int field_term_char,line_term_char,enclosed_char,escape_char; int *stack,*stack_pos; @@ -89,7 +90,7 @@ public: int read_fixed_length(void); int next_line(void); char unescape(char chr); - int terminator(char *ptr,uint length); + int terminator(const uchar *ptr, uint length); bool find_start_of_fields(); /* load xml */ List taglist; @@ -751,7 +752,7 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex, append_identifier(thd, &pfields, item->name, strlen(item->name)); // Extract exact Item value str->copy(); - pfields.append((char *)str->ptr()); + pfields.append(str->ptr()); str->free(); } /* @@ -767,17 +768,17 @@ static bool write_execute_load_query_log_event(THD *thd, sql_exchange* ex, if (!(load_data_query= (char *)thd->alloc(lle.get_query_buffer_length() + 1 + pl))) return TRUE; - lle.print_query(FALSE, (const char *) ex->cs?ex->cs->csname:NULL, + lle.print_query(FALSE, ex->cs ? ex->cs->csname : NULL, load_data_query, &end, - (char **)&fname_start, (char **)&fname_end); + &fname_start, &fname_end); strcpy(end, p); end += pl; Execute_load_query_log_event e(thd, load_data_query, end-load_data_query, - (uint) ((char*) fname_start - load_data_query - 1), - (uint) ((char*) fname_end - load_data_query), + static_cast(fname_start - load_data_query - 1), + static_cast(fname_end - load_data_query), (duplicates == DUP_REPLACE) ? LOAD_DUP_REPLACE : (ignore ? LOAD_DUP_IGNORE : LOAD_DUP_ERROR), transactional_table, FALSE, FALSE, errcode); @@ -1319,10 +1320,18 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs, found_end_of_line(false), eof(false), need_end_io_cache(false), error(false), line_cuted(false), found_null(false), read_charset(cs) { - field_term_ptr=(char*) field_term.ptr(); + /* + Field and line terminators must be interpreted as sequence of unsigned char. + Otherwise, non-ascii terminators will be negative on some platforms, + and positive on others (depending on the implementation of char). + */ + field_term_ptr= + static_cast(static_cast(field_term.ptr())); field_term_length= field_term.length(); - line_term_ptr=(char*) line_term.ptr(); + line_term_ptr= + static_cast(static_cast(line_term.ptr())); line_term_length= line_term.length(); + level= 0; /* for load xml */ if (line_start.length() == 0) { @@ -1331,7 +1340,7 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs, } else { - line_start_ptr=(char*) line_start.ptr(); + line_start_ptr= line_start.ptr(); line_start_end=line_start_ptr+line_start.length(); start_of_line= 1; } @@ -1340,12 +1349,12 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs, !memcmp(field_term_ptr,line_term_ptr,field_term_length)) { line_term_length=0; - line_term_ptr=(char*) ""; + line_term_ptr= NULL; } enclosed_char= (enclosed_length=enclosed_par.length()) ? (uchar) enclosed_par[0] : INT_MAX; - field_term_char= field_term_length ? (uchar) field_term_ptr[0] : INT_MAX; - line_term_char= line_term_length ? (uchar) line_term_ptr[0] : INT_MAX; + field_term_char= field_term_length ? field_term_ptr[0] : INT_MAX; + line_term_char= line_term_length ? line_term_ptr[0] : INT_MAX; /* Set of a stack for unget if long terminators */ @@ -1403,7 +1412,7 @@ READ_INFO::~READ_INFO() } -inline int READ_INFO::terminator(char *ptr,uint length) +inline int READ_INFO::terminator(const uchar *ptr,uint length) { int chr=0; // Keep gcc happy uint i; @@ -1418,7 +1427,7 @@ inline int READ_INFO::terminator(char *ptr,uint length) return 1; PUSH(chr); while (i-- > 1) - PUSH((uchar) *--ptr); + PUSH(*--ptr); return 0; } @@ -1549,7 +1558,7 @@ int READ_INFO::read_field() if (my_mbcharlen(read_charset, chr) > 1 && to + my_mbcharlen(read_charset, chr) <= end_of_buff) { - uchar* p= (uchar*) to; + uchar* p= to; int ml, i; *to++ = chr; @@ -1574,7 +1583,7 @@ int READ_INFO::read_field() (const char *)to)) continue; for (i= 0; i < ml; i++) - PUSH((uchar) *--to); + PUSH(*--to); chr= GET; } #endif @@ -1723,7 +1732,7 @@ bool READ_INFO::find_start_of_fields() return 1; } } while ((char) chr != line_start_ptr[0]); - for (char *ptr=line_start_ptr+1 ; ptr != line_start_end ; ptr++) + for (const char *ptr=line_start_ptr+1 ; ptr != line_start_end ; ptr++) { chr=GET; // Eof will be checked later if ((char) chr != *ptr) @@ -1731,7 +1740,7 @@ bool READ_INFO::find_start_of_fields() PUSH(chr); while (--ptr != line_start_ptr) { // Restart with next char - PUSH((uchar) *ptr); + PUSH( *ptr); } goto try_again; } @@ -1927,7 +1936,7 @@ int READ_INFO::read_xml() // row tag should be in ROWS IDENTIFIED BY '' - stored in line_term if((tag.length() == line_term_length -2) && - (strncmp(tag.c_ptr_safe(), line_term_ptr + 1, tag.length()) == 0)) + (memcmp(tag.ptr(), line_term_ptr + 1, tag.length()) == 0)) { DBUG_PRINT("read_xml", ("start-of-row: %i %s %s", level,tag.c_ptr_safe(), line_term_ptr)); @@ -1989,7 +1998,7 @@ int READ_INFO::read_xml() } if((tag.length() == line_term_length -2) && - (strncmp(tag.c_ptr_safe(), line_term_ptr + 1, tag.length()) == 0)) + (memcmp(tag.ptr(), line_term_ptr + 1, tag.length()) == 0)) { DBUG_PRINT("read_xml", ("found end-of-row %i %s", level, tag.c_ptr_safe())); From 501de3a027f11e33c14136f83e45dabe3d6f3102 Mon Sep 17 00:00:00 2001 From: Nisha Gopalakrishnan Date: Thu, 24 Apr 2014 09:30:21 +0530 Subject: [PATCH 21/25] BUG#18080920: CRASH; MY_REALLOC_STR DEREFERENCES NEGATIVE VALUE INTO CLIENT_ERRORS ARRAY Analysis: -------- The client may crash while executing a statement due to the missing mapping of the server error to it's equivalent client error. When trying to reallocate memory for the packet buffer, if the system is out of memory or the packet buffer is large, the server errors 'ER_OUT_OF_RESOURCES' or 'ER_PACKET_TOO_LARGE' is returned respectively. The client error number calculated is negative and when trying to dereference the array of client error messages with the calculated error number, the client crashes. Fix: ---- Map the server error returned to it's equivalent client error prior to dereferencing the array of client error messages. Note: Test case is not added since it is difficult to simulate the error condition. --- include/errmsg.h | 6 ++++-- libmysql/errmsg.c | 4 +++- libmysql/libmysql.c | 6 +++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/errmsg.h b/include/errmsg.h index 64ec2df395c..5655883466c 100644 --- a/include/errmsg.h +++ b/include/errmsg.h @@ -1,7 +1,7 @@ #ifndef ERRMSG_INCLUDED #define ERRMSG_INCLUDED -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2014, 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 @@ -32,7 +32,9 @@ extern const char *client_errors[]; /* Error messages */ #define CR_MIN_ERROR 2000 /* For easier client code */ #define CR_MAX_ERROR 2999 #if !defined(ER) -#define ER(X) client_errors[(X)-CR_MIN_ERROR] +#define ER(X) (((X) >= CR_ERROR_FIRST && (X) <= CR_ERROR_LAST)? \ + client_errors[(X)-CR_ERROR_FIRST]: client_errors[CR_UNKNOWN_ERROR]) + #endif #define CLIENT_ERRMAP 2 /* Errormap used by my_error() */ diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c index 498ba6e9829..81d2728534a 100644 --- a/libmysql/errmsg.c +++ b/libmysql/errmsg.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2014, 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 @@ -105,6 +105,8 @@ const char** get_client_errmsgs() void init_client_errs(void) { + compile_time_assert(array_elements(client_errors) == + (CR_ERROR_LAST - CR_ERROR_FIRST + 2)); (void) my_error_register(get_client_errmsgs, CR_ERROR_FIRST, CR_ERROR_LAST); } diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index d6bdea3df1f..6e7134ff97c 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2014, 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 @@ -1316,6 +1316,10 @@ static my_bool my_realloc_str(NET *net, ulong length) res= net_realloc(net, buf_length + length); if (res) { + if (net->last_errno == ER_OUT_OF_RESOURCES) + net->last_errno= CR_OUT_OF_MEMORY; + else if (net->last_errno == ER_NET_PACKET_TOO_LARGE) + net->last_errno= CR_NET_PACKET_TOO_LARGE; strmov(net->sqlstate, unknown_sqlstate); strmov(net->last_error, ER(net->last_errno)); } From 5e881cc435370140c38241dc6451f4cb31c0a3b9 Mon Sep 17 00:00:00 2001 From: Nisha Gopalakrishnan Date: Mon, 28 Apr 2014 16:28:09 +0530 Subject: [PATCH 22/25] BUG#17994219: CREATE TABLE .. SELECT PRODUCES INVALID STRUCTURE, BREAKS RBR Analysis: -------- A table created using a query of the format: CREATE TABLE t1 AS SELECT REPEAT('A',1000) DIV 1 AS a; breaks the Row Based Replication. The query above creates a table having a field of datatype 'bigint' with a display width of 3000 which is beyond the maximum acceptable value of 255. In the RBR mode, CREATE TABLE SELECT statement is replicated as a combination of CREATE TABLE statement equivalent to one the returned by SHOW CREATE TABLE and row events for rows inserted. When this CREATE TABLE event is executed on the slave, an error is reported: Display width out of range for column 'a' (max = 255) The following is the output of 'SHOW CREATE TABLE t1': CREATE TABLE t1(`a` bigint(3000) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1; The problem is due to the combination of two facts: 1) The above CREATE TABLE SELECT statement uses the display width of the result of DIV operation as the display width of the column created without validating the width for out of bound condition. 2) The DIV operation incorrectly returns the length of its first argument as the display width of its result; thus allowing creation of a table with an incorrect display width of 3000 for the field. Fix: ---- This fix changes the DIV operation implementation to correctly evaluate the display width of its result. We check if DIV's results estimated width crosses maximum width for integer value (21) and if yes set it to this maximum value. This patch also fixes fixes maximum display width evaluation for DIV function when its first argument is in UCS2. --- .../suite/rpl/r/rpl_row_create_select.result | 28 +++++++++++++++++++ .../suite/rpl/t/rpl_row_create_select.test | 28 +++++++++++++++++++ sql/item_func.cc | 10 ++++--- 3 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_row_create_select.result create mode 100644 mysql-test/suite/rpl/t/rpl_row_create_select.test diff --git a/mysql-test/suite/rpl/r/rpl_row_create_select.result b/mysql-test/suite/rpl/r/rpl_row_create_select.result new file mode 100644 index 00000000000..719bfae3f0c --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_row_create_select.result @@ -0,0 +1,28 @@ +include/master-slave.inc +[connection master] +# +# BUG#17994219: CREATE TABLE .. SELECT PRODUCES INVALID STRUCTURE, +# BREAKS RBR +# +#After the patch, the display width is set to a default +#value of 21. +CREATE TABLE t1 AS SELECT REPEAT('A', 1000) DIV 1 AS a; +Warnings: +Warning 1366 Incorrect decimal value: '' for column '' at row -1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(21) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +CREATE TABLE t2 AS SELECT CONVERT(REPEAT('A', 255) USING UCS2) DIV 1 AS a; +Warnings: +Warning 1366 Incorrect decimal value: '' for column '' at row -1 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` bigint(21) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +#After the patch, no error is reported. +DROP TABLE t1; +DROP TABLE t2; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_row_create_select.test b/mysql-test/suite/rpl/t/rpl_row_create_select.test new file mode 100644 index 00000000000..ca270e92d0c --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_row_create_select.test @@ -0,0 +1,28 @@ +# Testing table creations for row-based replication. + +--source include/have_binlog_format_row.inc +--source include/master-slave.inc + +--echo # +--echo # BUG#17994219: CREATE TABLE .. SELECT PRODUCES INVALID STRUCTURE, +--echo # BREAKS RBR +--echo # + +connection master; +--echo #After the patch, the display width is set to a default +--echo #value of 21. +CREATE TABLE t1 AS SELECT REPEAT('A', 1000) DIV 1 AS a; +SHOW CREATE TABLE t1; + +CREATE TABLE t2 AS SELECT CONVERT(REPEAT('A', 255) USING UCS2) DIV 1 AS a; +SHOW CREATE TABLE t2; + +--echo #After the patch, no error is reported. +sync_slave_with_master; + +connection master; +DROP TABLE t1; +DROP TABLE t2; + +--source include/rpl_end.inc + diff --git a/sql/item_func.cc b/sql/item_func.cc index 39c05d63150..3e3079f317f 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2014, 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 @@ -1649,9 +1649,11 @@ void Item_func_int_div::fix_length_and_dec() { Item_result argtype= args[0]->result_type(); /* use precision ony for the data type it is applicable for and valid */ - max_length=args[0]->max_length - - (argtype == DECIMAL_RESULT || argtype == INT_RESULT ? - args[0]->decimals : 0); + uint32 char_length= args[0]->max_char_length() - + (argtype == DECIMAL_RESULT || argtype == INT_RESULT ? + args[0]->decimals : 0); + fix_char_length(char_length > MY_INT64_NUM_DECIMAL_DIGITS ? + MY_INT64_NUM_DECIMAL_DIGITS : char_length); maybe_null=1; unsigned_flag=args[0]->unsigned_flag | args[1]->unsigned_flag; } From 3d6d85b40dbe8938d8d2972053e0ea714c04a2d4 Mon Sep 17 00:00:00 2001 From: mithun Date: Mon, 28 Apr 2014 21:07:27 +0530 Subject: [PATCH 23/25] Bug #18167356: EXPLAIN W/ EXISTS(SELECT* UNION SELECT*) WHERE ONE OF SELECT* IS DISTINCT FAILS. ISSUE: ------ There are 2 issues related to explain union. 1. If we have subquery with union of selects. And, one of the select need temp table to materialize its results then it will replace its query structure with a simple select from temporary table. Trying to display new internal temporary table scan resulted in crash. But to display the query plan, we should save the original query structure. 2. Multiple execution of prepared explain statement which have union of subqueries resulted in crash. If we have constant subqueries, fake select used in union operation will be evaluated once before using it for explain. During first execution we have set fake select options to SELECT_DESCRIBE, but did not reset after the explain. Hence during next execution of prepared statement during first time evaluation of fake select we had our select options as SELECT_DESCRIBE this resulted in improperly initialized data structures and crash. SOLUTION: --------- 1. If called by explain now we save the original query structure. And this will be used for displaying. 2. Reset the fake select options after it is called for explain of union. sql/sql_select.cc: Reset the fake select options after it is called for explain of union sql/sql_union.cc: If called by explain but not from select_describe and we need a temp table, then we create a temp join to preserve original query structure. --- sql/sql_select.cc | 5 +++++ sql/sql_union.cc | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index fbb5d00e7a8..860a4b7f5dc 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -17299,6 +17299,11 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result) unit->fake_select_lex->options|= SELECT_DESCRIBE; if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK | SELECT_DESCRIBE))) res= unit->exec(); + /* + Reset select option. Needed if fake_select_lex is used and not called + from select describe. + */ + unit->fake_select_lex->options&= ~SELECT_DESCRIBE; res|= unit->cleanup(); } else diff --git a/sql/sql_union.cc b/sql/sql_union.cc index b0a25c2df97..d0660e8f117 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -511,6 +511,35 @@ bool st_select_lex_unit::exec() (select_limit_cnt == HA_POS_ERROR || sl->braces) ? sl->options & ~OPTION_FOUND_ROWS : sl->options | found_rows_for_union; saved_error= sl->join->optimize(); + + /* + If called by explain statement then we may need to save the original + JOIN LAYOUT so that we can display the plan. Otherwise original plan + will be replaced by a simple scan on temp table if subquery uses temp + table. + We check for following conditions to force join_tmp creation + 1. This is an EXPLAIN statement, and + 2. JOIN not yet saved in JOIN::optimize(), and + 3. Not called directly from select_describe(), and + 4. Belongs to a subquery that is const, and + 5. Need a temp table. + */ + if (thd->lex->describe && // 1 + !sl->uncacheable && // 2 + !(sl->join->select_options & SELECT_DESCRIBE) && // 3 + item && item->const_item()) // 4 + { + /* + Force join->join_tmp creation, because this subquery will be + replaced by a simple select from the materialization temp table + by optimize() called by EXPLAIN and we need to preserve the + initial query structure so we can display it. + */ + sl->uncacheable|= UNCACHEABLE_EXPLAIN; + sl->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN; + if (sl->join->need_tmp && sl->join->init_save_join_tab()) // 5 + DBUG_RETURN(1); + } } if (!saved_error) { From d14f191e6b2c1e967b8087f36e09b019cfe20930 Mon Sep 17 00:00:00 2001 From: Alexander Nozdrin Date: Wed, 30 Apr 2014 20:48:29 +0400 Subject: [PATCH 24/25] Patch for Bug#18511348 (DDL_I18N_UTF8 AND DDL_I18N_KOI8R ARE PERMANENTLY SKIPPED IN 5.5/5.6). The problem was that some result files were not updated, so the tests were skipped. The fix is to record updated result files. --- mysql-test/r/have_cp1251.require | 2 +- mysql-test/r/have_cp866.require | 2 +- mysql-test/r/have_koi8r.require | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/have_cp1251.require b/mysql-test/r/have_cp1251.require index 465e8338084..a4e66df9eac 100644 --- a/mysql-test/r/have_cp1251.require +++ b/mysql-test/r/have_cp1251.require @@ -1,2 +1,2 @@ Collation Charset Id Default Compiled Sortlen -cp1251_general_ci cp1251 51 Yes 0 +cp1251_general_ci cp1251 51 Yes Yes 1 diff --git a/mysql-test/r/have_cp866.require b/mysql-test/r/have_cp866.require index da2a3e2f05e..7efa36b957c 100644 --- a/mysql-test/r/have_cp866.require +++ b/mysql-test/r/have_cp866.require @@ -1,2 +1,2 @@ Collation Charset Id Default Compiled Sortlen -cp866_general_ci cp866 36 Yes 0 +cp866_general_ci cp866 36 Yes Yes 1 diff --git a/mysql-test/r/have_koi8r.require b/mysql-test/r/have_koi8r.require index b109b9ae520..2df3fdd243d 100644 --- a/mysql-test/r/have_koi8r.require +++ b/mysql-test/r/have_koi8r.require @@ -1,2 +1,2 @@ Collation Charset Id Default Compiled Sortlen -koi8r_general_ci koi8r 7 Yes 0 +koi8r_general_ci koi8r 7 Yes Yes 1 From c1fd09f3d4848ae59605564ded9628307d59dd27 Mon Sep 17 00:00:00 2001 From: Balasubramanian Kandasamy Date: Sun, 11 May 2014 18:24:12 +0200 Subject: [PATCH 25/25] Increment release version to resolve upgrade conflict issue --- packaging/rpm-oel/mysql.spec.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packaging/rpm-oel/mysql.spec.in b/packaging/rpm-oel/mysql.spec.in index 959bcc0e3e3..d28e89b4216 100644 --- a/packaging/rpm-oel/mysql.spec.in +++ b/packaging/rpm-oel/mysql.spec.in @@ -85,7 +85,7 @@ Name: mysql-%{product_suffix} Summary: A very fast and reliable SQL database server Group: Applications/Databases Version: @VERSION@ -Release: 1%{?commercial:.1}%{?dist} +Release: 2%{?commercial:.1}%{?dist} License: Copyright (c) 2000, @MYSQL_COPYRIGHT_YEAR@, %{mysql_vendor}. All rights reserved. Under %{?license_type} license as shown in the Description field. Source0: https://cdn.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/%{src_dir}.tar.gz URL: http://www.mysql.com/ @@ -881,6 +881,9 @@ fi %endif %changelog +* Sun May 11 2014 Balasubramanian Kandasamy - 5.5.38-2 +- Increment release version to resolve upgrade conflict issue + * Thu Apr 24 2014 Balasubramanian Kandasamy - 5.5.38-1 - Updated for 5.5.38