diff --git a/CMakeLists.txt b/CMakeLists.txt
index 375f6bb64bceb8d19329434b8a29e5e24346edbb..6bb269abe760c97d16b5369051868a4cbbddf1e4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,10 +28,12 @@ ENDIF()
 
 # We use the LOCATION target property (CMP0026)
 # and get_target_property() for non-existent targets (CMP0045)
+# and INSTALL_NAME_DIR (CMP0042)
 IF(CMAKE_VERSION VERSION_EQUAL "3.0.0" OR
    CMAKE_VERSION VERSION_GREATER "3.0.0")
  CMAKE_POLICY(SET CMP0026 OLD)
  CMAKE_POLICY(SET CMP0045 OLD)
+ CMAKE_POLICY(SET CMP0042 OLD)
 ENDIF()
 
 MESSAGE(STATUS "Running cmake version ${CMAKE_VERSION}")
@@ -108,36 +110,15 @@ FOREACH(_base
 ENDFOREACH()
 
 
-
 # Following autotools tradition, add preprocessor definitions
 # specified in environment variable CPPFLAGS
 IF(DEFINED ENV{CPPFLAGS})
   ADD_DEFINITIONS($ENV{CPPFLAGS})
 ENDIF()
 
-#
-# Control aspects of the development environment which are
-# specific to MySQL maintainers and developers.
-#
-INCLUDE(maintainer)
-
 SET(MYSQL_MAINTAINER_MODE "AUTO" CACHE STRING "MySQL maintainer-specific development environment. Options are: ON OFF AUTO.")
 MARK_AS_ADVANCED(MYSQL_MAINTAINER_MODE)
 
-# Whether the maintainer mode compiler options should be enabled.
-IF(CMAKE_C_COMPILER_ID MATCHES "GNU")
-  SET_MYSQL_MAINTAINER_GNU_C_OPTIONS()
-ENDIF()
-IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
-  SET_MYSQL_MAINTAINER_GNU_CXX_OPTIONS()
-ENDIF()
-IF(CMAKE_C_COMPILER_ID MATCHES "Intel")
-  SET_MYSQL_MAINTAINER_INTEL_C_OPTIONS()
-ENDIF()
-IF(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
-  SET_MYSQL_MAINTAINER_INTEL_CXX_OPTIONS()
-ENDIF()
-
 # Packaging
 IF (NOT CPACK_GENERATOR)
   IF(WIN32)
@@ -183,7 +164,7 @@ OPTION (WITH_UNIT_TESTS "Compile MySQL with unit tests" ON)
 MARK_AS_ADVANCED(CYBOZU BACKUP_TEST WITHOUT_SERVER DISABLE_SHARED)
 
 OPTION(NOT_FOR_DISTRIBUTION "Allow linking with GPLv2-incompatible system libraries. Only set it you never plan to distribute the resulting binaries" OFF)
- 
+
 include(CheckCSourceCompiles)
 include(CheckCXXSourceCompiles)
 # We need some extra FAIL_REGEX patterns
@@ -374,13 +355,7 @@ CHECK_JEMALLOC()
 # not run with the warning options as to not perturb fragile checks
 # (i.e. do not make warnings into errors).
 #
-IF(MYSQL_MAINTAINER_MODE MATCHES "ON")
-  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_MAINTAINER_C_WARNINGS}")
-  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_MAINTAINER_CXX_WARNINGS}")
-ELSEIF(MYSQL_MAINTAINER_MODE MATCHES "AUTO")
-  SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${MY_MAINTAINER_C_WARNINGS}")
-  SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MY_MAINTAINER_CXX_WARNINGS}")
-ENDIF()
+INCLUDE(maintainer)
 
 IF(WITH_UNIT_TESTS)
  ENABLE_TESTING()
@@ -494,4 +469,3 @@ IF(NON_DISTRIBUTABLE_WARNING)
   MESSAGE(WARNING "
 You have linked MariaDB with GPLv3 libraries!  You may not distribute the resulting binary. If you do, you will put yourself into a legal problem with Free Software Foundation.")
 ENDIF()
-
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 990fadadae21ba2a1df5d84084cc02af43419a5e..57492577e9182d2ab0a929f7faa46bbed90f32b6 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -1,6 +1,6 @@
 /*
-   Copyright (c) 2000, 2013, Oracle and/or its affiliates.
-   Copyright (c) 2009, 2013, Monty Program Ab.
+   Copyright (c) 2000, 2014, Oracle and/or its affiliates.
+   Copyright (c) 2009, 2014, MariaDB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -2413,6 +2413,7 @@ int main(int argc, char** argv)
   DBUG_PROCESS(argv[0]);
 
   my_init_time(); // for time functions
+  tzset(); // set tzname
 
   init_alloc_root(&s_mem_root, 16384, 0);
   if (load_defaults("my", load_groups, &argc, &argv))
diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake
index 543b66477bd60e29c29c684f69af6c1c114d048d..2c0e7699c8d80c3c9d501161e9457179626126b1 100644
--- a/cmake/build_configurations/mysql_release.cmake
+++ b/cmake/build_configurations/mysql_release.cmake
@@ -201,15 +201,16 @@ IF(UNIX)
     ENDIF()
   ENDIF()
 
-  # OSX flags
-  IF(APPLE)
-    SET(COMMON_C_FLAGS                 "-g -fno-common -fno-strict-aliasing")
-    # XXX: why are we using -felide-constructors on OSX?
-    SET(COMMON_CXX_FLAGS               "-g -fno-common -felide-constructors -fno-strict-aliasing")
-    SET(CMAKE_C_FLAGS_DEBUG            "-O ${COMMON_C_FLAGS}")
-    SET(CMAKE_CXX_FLAGS_DEBUG          "-O ${COMMON_CXX_FLAGS}")
-    SET(CMAKE_C_FLAGS_RELWITHDEBINFO   "-Os ${COMMON_C_FLAGS}")
-    SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os ${COMMON_CXX_FLAGS}")
+  # Default Clang flags
+  IF(CMAKE_C_COMPILER_ID MATCHES "Clang")
+    SET(COMMON_C_FLAGS               "-g -fno-omit-frame-pointer -fno-strict-aliasing")
+    SET(CMAKE_C_FLAGS_DEBUG          "${COMMON_C_FLAGS}")
+    SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_C_FLAGS}")
+  ENDIF()
+  IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+    SET(COMMON_CXX_FLAGS               "-g -fno-omit-frame-pointer -fno-strict-aliasing")
+    SET(CMAKE_CXX_FLAGS_DEBUG          "${COMMON_CXX_FLAGS}")
+    SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_CXX_FLAGS}")
   ENDIF()
 
   # Solaris flags
diff --git a/cmake/compile_flags.cmake b/cmake/compile_flags.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..5e872f981b0cd27991d3751b0bc8791c5df2746e
--- /dev/null
+++ b/cmake/compile_flags.cmake
@@ -0,0 +1,44 @@
+# Copyright (c) 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
+# 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 General Public License for more details.
+# 
+# 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
+
+
+## ADD_COMPILE_FLAGS(<source files> COMPILE_FLAGS <flags>)
+MACRO(ADD_COMPILE_FLAGS)
+  SET(FILES "")
+  SET(FLAGS "")
+  SET(COMPILE_FLAGS)
+  FOREACH(ARG ${ARGV})
+    IF(ARG STREQUAL "COMPILE_FLAGS")
+      SET(COMPILE_FLAGS "COMPILE_FLAGS")
+    ELSEIF(COMPILE_FLAGS)
+      LIST(APPEND FLAGS ${ARG})
+    ELSE()
+      LIST(APPEND FILES ${ARG})
+    ENDIF()
+  ENDFOREACH()
+  FOREACH(FILE ${FILES})
+    FOREACH(FLAG ${FLAGS})
+      GET_SOURCE_FILE_PROPERTY(PROP ${FILE} COMPILE_FLAGS)
+      IF(NOT PROP)
+        SET(PROP ${FLAG})
+      ELSE()
+        SET(PROP "${PROP} ${FLAG}")
+      ENDIF()
+      SET_SOURCE_FILES_PROPERTIES(
+        ${FILE} PROPERTIES COMPILE_FLAGS "${PROP}"
+        )
+    ENDFOREACH()
+  ENDFOREACH()
+ENDMACRO()
diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake
index 9c9ab8cca3bdcb67f2617cb0154855c3f0629ae2..5d3ce4d1f75a6484c32916cddce7aefc608635c8 100644
--- a/cmake/maintainer.cmake
+++ b/cmake/maintainer.cmake
@@ -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
@@ -13,51 +13,46 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
-INCLUDE(CheckCCompilerFlag)
-
-# Setup GCC (GNU C compiler) warning options.
-MACRO(SET_MYSQL_MAINTAINER_GNU_C_OPTIONS)
-  SET(MY_MAINTAINER_WARNINGS
-      "-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing")
-
-  CHECK_C_COMPILER_FLAG("-Wno-missing-field-initializers"
-    HAVE_NO_MISSING_FIELD_INITIALIZERS)
-
-  IF (HAVE_NO_MISSING_FIELD_INITIALIZERS)
-    SET(MY_MAINTAINER_WARNINGS
-      "${MY_MAINTAINER_WARNINGS} -Wno-missing-field-initializers")
-  ENDIF()
-
-  CHECK_C_COMPILER_FLAG("-Wdeclaration-after-statement"
-                        HAVE_DECLARATION_AFTER_STATEMENT)
-  IF(HAVE_DECLARATION_AFTER_STATEMENT)
-    SET(MY_MAINTAINER_DECLARATION_AFTER_STATEMENT
-        "-Wdeclaration-after-statement")
-  ENDIF()
-  SET(MY_MAINTAINER_C_WARNINGS
-      "${MY_MAINTAINER_WARNINGS} ${MY_MAINTAINER_DECLARATION_AFTER_STATEMENT}"
-      CACHE INTERNAL "C warning options used in maintainer builds.")
-  # Do not make warnings in checks into errors.
-  SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-error")
-ENDMACRO()
-
-# Setup G++ (GNU C++ compiler) warning options.
-MACRO(SET_MYSQL_MAINTAINER_GNU_CXX_OPTIONS)
-  SET(MY_MAINTAINER_CXX_WARNINGS
-      "${MY_MAINTAINER_WARNINGS} -Wno-unused-parameter -Woverloaded-virtual"
-      CACHE INTERNAL "C++ warning options used in maintainer builds.")
-ENDMACRO()
-
-# Setup ICC (Intel C Compiler) warning options.
-MACRO(SET_MYSQL_MAINTAINER_INTEL_C_OPTIONS)
-  SET(MY_MAINTAINER_WARNINGS "-Wcheck")
-  SET(MY_MAINTAINER_C_WARNINGS "${MY_MAINTAINER_WARNINGS}"
-    CACHE INTERNAL "C warning options used in maintainer builds.")
-ENDMACRO()
-
-# Setup ICPC (Intel C++ Compiler) warning options.
-MACRO(SET_MYSQL_MAINTAINER_INTEL_CXX_OPTIONS)
-  SET(MY_MAINTAINER_CXX_WARNINGS "${MY_MAINTAINER_WARNINGS}"
-    CACHE INTERNAL "C++ warning options used in maintainer builds.")
-ENDMACRO()
-
+# Common warning flags for GCC, G++, Clang and Clang++
+SET(MY_WARNING_FLAGS "-Wall -Wextra -Wformat-security")
+MY_CHECK_C_COMPILER_FLAG("-Wvla" HAVE_WVLA) # Requires GCC 4.3+ or Clang
+IF(HAVE_WVLA)
+  SET(MY_WARNING_FLAGS "${MY_WARNING_FLAGS} -Wvla")
+ENDIF()
+
+# Common warning flags for GCC and Clang
+SET(MY_C_WARNING_FLAGS
+    "${MY_WARNING_FLAGS} -Wwrite-strings -Wdeclaration-after-statement")
+
+# Common warning flags for G++ and Clang++
+SET(MY_CXX_WARNING_FLAGS
+    "${MY_WARNING_FLAGS} -Woverloaded-virtual -Wno-unused-parameter")
+
+# Extra warning flags for Clang++
+IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  SET(MY_CXX_WARNING_FLAGS
+      "${MY_CXX_WARNING_FLAGS} -Wno-null-conversion -Wno-unused-private-field")
+ENDIF()
+
+# Turn on Werror (warning => error) when using maintainer mode.
+IF(MYSQL_MAINTAINER_MODE MATCHES "ON")
+  SET(MY_C_WARNING_FLAGS "${MY_C_WARNING_FLAGS} -Werror")
+  SET(MY_CXX_WARNING_FLAGS "${MY_CXX_WARNING_FLAGS} -Werror")
+ENDIF()
+
+# Set warning flags for GCC/Clang
+IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
+  SET(MY_MAINTAINER_C_WARNINGS "${MY_C_WARNING_FLAGS}")
+ENDIF()
+# Set warning flags for G++/Clang++
+IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  SET(MY_MAINTAINER_CXX_WARNINGS "${MY_CXX_WARNING_FLAGS}")
+ENDIF()
+
+IF(MYSQL_MAINTAINER_MODE MATCHES "ON")
+  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_MAINTAINER_C_WARNINGS}")
+  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_MAINTAINER_CXX_WARNINGS}")
+ELSEIF(MYSQL_MAINTAINER_MODE MATCHES "AUTO")
+  SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${MY_MAINTAINER_C_WARNINGS}")
+  SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MY_MAINTAINER_CXX_WARNINGS}")
+ENDIF()
diff --git a/cmake/os/Darwin.cmake b/cmake/os/Darwin.cmake
index 0d8bac106f0ff5d2503688f75f1b5b93b822717a..4ac72070e8bd3ab70907ea0bfd027523bf08d15f 100644
--- a/cmake/os/Darwin.cmake
+++ b/cmake/os/Darwin.cmake
@@ -1,5 +1,4 @@
-# Copyright (c) 2010 Sun Microsystems, Inc.
-# Use is subject to license terms.
+# 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
@@ -15,21 +14,3 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
 
 # This file includes OSX specific options and quirks, related to system checks
-
-# Workaround for CMake bug#9051
-# (CMake does not pass CMAKE_OSX_SYSROOT and CMAKE_OSX_DEPLOYMENT_TARGET when 
-# running TRY_COMPILE)
-
-IF(CMAKE_OSX_SYSROOT)
- SET(ENV{CMAKE_OSX_SYSROOT} ${CMAKE_OSX_SYSROOT})
-ENDIF()
-IF(CMAKE_OSX_SYSROOT)
- SET(ENV{MACOSX_DEPLOYMENT_TARGET} ${OSX_DEPLOYMENT_TARGET})
-ENDIF()
-
-IF(CMAKE_OSX_DEPLOYMENT_TARGET)
-  # Workaround linker problems  on OSX 10.4
-  IF(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "10.5")
-    ADD_DEFINITIONS(-fno-common)
-  ENDIF()
-ENDIF()
diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake
index 1453cc55053fd57373e915ea7a415bcfb75cc9e1..c75f2e45bf6a8c8b0677449dc4e55739ac82972b 100644
--- a/cmake/os/WindowsCache.cmake
+++ b/cmake/os/WindowsCache.cmake
@@ -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
@@ -90,7 +90,7 @@ SET(HAVE_GETRLIMIT CACHE  INTERNAL "")
 SET(HAVE_GETRUSAGE CACHE  INTERNAL "")
 SET(HAVE_GETTIMEOFDAY CACHE  INTERNAL "")
 SET(HAVE_GETWD CACHE  INTERNAL "")
-SET(HAVE_GMTIME_R CACHE  INTERNAL "")
+SET(HAVE_GMTIME_R 1 CACHE  INTERNAL "")
 SET(HAVE_GRP_H CACHE  INTERNAL "")
 SET(HAVE_IA64INTRIN_H CACHE  INTERNAL "")
 SET(HAVE_IEEEFP_H CACHE  INTERNAL "")
@@ -111,7 +111,7 @@ SET(HAVE_LANGINFO_H CACHE  INTERNAL "")
 SET(HAVE_LDIV 1 CACHE  INTERNAL "")
 SET(HAVE_LIMITS_H 1 CACHE  INTERNAL "")
 SET(HAVE_LOCALE_H 1 CACHE  INTERNAL "")
-SET(HAVE_LOCALTIME_R CACHE  INTERNAL "")
+SET(HAVE_LOCALTIME_R 1 CACHE  INTERNAL "")
 SET(HAVE_LOG2 CACHE  INTERNAL "")
 SET(HAVE_LONGJMP 1 CACHE  INTERNAL "")
 SET(HAVE_LRAND48 CACHE  INTERNAL "")
diff --git a/configure.cmake b/configure.cmake
index 0bd7bbe38a1d383bda28fd12294908e06f165d64..1e64e0586701421d56d3c484cd1906b73ef64f15 100644
--- a/configure.cmake
+++ b/configure.cmake
@@ -53,15 +53,6 @@ IF(NOT SYSTEM_TYPE)
 ENDIF()
 
 
-# Always enable -Wall for gnu C/C++
-IF(CMAKE_COMPILER_IS_GNUCXX)
-  SET(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
-ENDIF()
-IF(CMAKE_COMPILER_IS_GNUCC)
-  SET(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}")
-ENDIF()
-
-
 IF(CMAKE_COMPILER_IS_GNUCXX)
   # MySQL "canonical" GCC flags. At least -fno-rtti flag affects
   # ABI and cannot be simply removed. 
diff --git a/extra/replace.c b/extra/replace.c
index c4105e459736ca8b255ab5f716bd377e70e9c189..56cf02f20023697dab2887855af6243dc6c9119d 100644
--- a/extra/replace.c
+++ b/extra/replace.c
@@ -1,5 +1,5 @@
 /*
-   Copyright (c) 2000, 2011, Oracle and/or its affiliates
+   Copyright (c) 2000, 2014, 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
@@ -1021,7 +1021,7 @@ FILE *in,*out;
   updated=retain=0;
   reset_buffer();
 
-  while ((error=fill_buffer_retaining(fileno(in),retain)) > 0)
+  while ((error=fill_buffer_retaining(my_fileno(in),retain)) > 0)
   {
     end_of_line=buffer ;
     buffer[bufbytes]=0;			/* Sentinel  */
diff --git a/extra/yassl/README b/extra/yassl/README
index b18e2baeea8fd6796d46ac0b61ef6915698a953a..30c7af4a702a80e8e0f334aa2b6eebe9a851f1d5 100644
--- a/extra/yassl/README
+++ b/extra/yassl/README
@@ -12,6 +12,15 @@ before calling SSL_new();
 
 *** end Note ***
 
+yaSSL Release notes, version 2.3.5 (9/29/2014)
+
+    This release of yaSSL fixes an RSA Padding check vulnerability reported by
+    Intel Security Advanced Threat Research team
+
+See normal  build instructions below under 1.0.6.
+See libcurl build instructions below under 1.3.0 and note in 1.5.8.
+
+
 yaSSL Release notes, version 2.3.4 (8/15/2014)
 
     This release of yaSSL adds checking to the input_buffer class itself.
diff --git a/extra/yassl/include/openssl/ssl.h b/extra/yassl/include/openssl/ssl.h
index 993822d0ab06b96c5599806606e57c60578781a5..e678c600fed719f2492c50ec73d8eaf4613c8e5c 100644
--- a/extra/yassl/include/openssl/ssl.h
+++ b/extra/yassl/include/openssl/ssl.h
@@ -35,7 +35,7 @@
 #include "rsa.h"
 
 
-#define YASSL_VERSION "2.3.4"
+#define YASSL_VERSION "2.3.5"
 
 
 #if defined(__cplusplus)
diff --git a/extra/yassl/taocrypt/src/rsa.cpp b/extra/yassl/taocrypt/src/rsa.cpp
index 69c59402e489b00a3dd55bcecfeb414bbfcf685a..79a8a8f1c4f21848f5e3454320097da6fb71212d 100644
--- a/extra/yassl/taocrypt/src/rsa.cpp
+++ b/extra/yassl/taocrypt/src/rsa.cpp
@@ -177,7 +177,7 @@ word32 RSA_BlockType1::UnPad(const byte* pkcsBlock, word32 pkcsBlockLen,
 
     // skip past the padding until we find the separator
     unsigned i=1;
-    while (i<pkcsBlockLen && pkcsBlock[i++]) { // null body
+    while (i<pkcsBlockLen && pkcsBlock[i++] == 0xFF) { // null body
         }
     if (!(i==pkcsBlockLen || pkcsBlock[i-1]==0))
         return 0;
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 3a3f304dcff938473e7dcbcd70408a90c4e19a94..17c971cd621754a6c1252d858ce8aa0577f80625 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -1,5 +1,5 @@
-/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
-   Copyright (c) 2009, 2013, Monty Program Ab.
+/* Copyright (c) 2000, 2014, Oracle and/or its affiliates.
+   Copyright (c) 2009, 2014, MariaDB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -104,8 +104,18 @@ int pthread_attr_init(pthread_attr_t *connect_att);
 int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack);
 int pthread_attr_destroy(pthread_attr_t *connect_att);
 int my_pthread_once(my_pthread_once_t *once_control,void (*init_routine)(void));
-struct tm *localtime_r(const time_t *timep,struct tm *tmp);
-struct tm *gmtime_r(const time_t *timep,struct tm *tmp);
+
+static inline struct tm *localtime_r(const time_t *timep, struct tm *tmp)
+{
+  localtime_s(tmp, timep);
+  return tmp;
+}
+
+static inline struct tm *gmtime_r(const time_t *clock, struct tm *res)
+{
+  gmtime_s(res, clock);
+  return res;
+}
 
 void pthread_exit(void *a);
 int pthread_join(pthread_t thread, void **value_ptr);
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index db6cb2bf5616ce0f0bbc3fab4398e78aeb644034..3d6ca5a381046162760a51f1fd3c2c9ecc752e9f 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -2,6 +2,9 @@
  * Copyright (c)  2000
  * SWsoft  company
  *
+ * Modifications copyright (c) 2001, 2013. Oracle and/or its affiliates.
+ * All rights reserved.
+ *
  * This material is provided "as is", with absolutely no warranty expressed
  * or implied. Any use is at your own risk.
  *
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 60e0399efd49759164305c685c9ec5eee914805e..60f3475bd1791cb65bee2c56ebcd0e1a0474cafb 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -255,6 +255,7 @@ our $opt_ddd;
 our $opt_client_ddd;
 my $opt_boot_ddd;
 our $opt_manual_gdb;
+our $opt_manual_lldb;
 our $opt_manual_dbx;
 our $opt_manual_ddd;
 our $opt_manual_debug;
@@ -1156,6 +1157,7 @@ sub command_line_setup {
              'gdb'                      => \$opt_gdb,
              'client-gdb'               => \$opt_client_gdb,
              'manual-gdb'               => \$opt_manual_gdb,
+             'manual-lldb'              => \$opt_manual_lldb,
 	     'boot-gdb'                 => \$opt_boot_gdb,
              'manual-debug'             => \$opt_manual_debug,
              'ddd'                      => \$opt_ddd,
@@ -1596,8 +1598,9 @@ sub command_line_setup {
       $opt_debugger= undef;
     }
 
-    if ( $opt_gdb || $opt_ddd || $opt_manual_gdb || $opt_manual_ddd ||
-	 $opt_manual_debug || $opt_debugger || $opt_dbx || $opt_manual_dbx)
+    if ( $opt_gdb || $opt_ddd || $opt_manual_gdb || $opt_manual_lldb || 
+         $opt_manual_ddd || $opt_manual_debug || $opt_debugger || $opt_dbx || 
+         $opt_manual_dbx)
     {
       mtr_error("You need to use the client debug options for the",
 		"embedded server. Ex: --client-gdb");
@@ -1624,9 +1627,9 @@ sub command_line_setup {
   # --------------------------------------------------------------------------
   # Check debug related options
   # --------------------------------------------------------------------------
-  if ( $opt_gdb || $opt_client_gdb || $opt_ddd || $opt_client_ddd ||
-       $opt_manual_gdb || $opt_manual_ddd || $opt_manual_debug ||
-       $opt_dbx || $opt_client_dbx || $opt_manual_dbx ||
+  if ( $opt_gdb || $opt_client_gdb || $opt_ddd || $opt_client_ddd || 
+       $opt_manual_gdb || $opt_manual_lldb || $opt_manual_ddd || 
+       $opt_manual_debug || $opt_dbx || $opt_client_dbx || $opt_manual_dbx || 
        $opt_debugger || $opt_client_debugger )
   {
     if ( using_extern() )
@@ -2487,6 +2490,14 @@ sub environment_setup {
                                  "$bindir/sql$opt_vs_config/mysql_tzinfo_to_sql");
   $ENV{'MYSQL_TZINFO_TO_SQL'}= native_path($exe_mysql_tzinfo_to_sql);
 
+  # ----------------------------------------------------
+  # replace
+  # ----------------------------------------------------
+  my $exe_replace= mtr_exe_exists(vs_config_dirs('extra', 'replace'),
+                                 "$basedir/extra/replace",
+                                 "$path_client_bindir/replace");
+  $ENV{'REPLACE'}= native_path($exe_replace);
+
   # Create an environment variable to make it possible
   # to detect that valgrind is being used from test cases
   $ENV{'VALGRIND_TEST'}= $opt_valgrind;
@@ -5429,6 +5440,10 @@ sub mysqld_start ($$) {
   {
     gdb_arguments(\$args, \$exe, $mysqld->name());
   }
+  elsif ( $opt_manual_lldb )
+  {
+    lldb_arguments(\$args, \$exe, $mysqld->name());
+  }
   elsif ( $opt_ddd || $opt_manual_ddd )
   {
     ddd_arguments(\$args, \$exe, $mysqld->name());
@@ -5975,7 +5990,6 @@ sub start_mysqltest ($) {
   return $proc;
 }
 
-
 #
 # Modify the exe and args so that program is run in gdb in xterm
 #
@@ -6026,6 +6040,32 @@ sub gdb_arguments {
   $$exe= "xterm";
 }
 
+#
+# Modify the exe and args so that program is run in lldb
+#
+sub lldb_arguments {
+  my $args= shift;
+  my $exe= shift;
+  my $type= shift;
+  my $input= shift;
+
+  my $lldb_init_file= "$opt_vardir/tmp/lldbinit.$type";
+  unlink($lldb_init_file);
+
+  # Put $args into a single string
+  my $str= join(" ", @$$args);
+  $input = $input ? "< $input" : "";
+
+  # write init file for mysqld or client
+  mtr_tofile($lldb_init_file, "set args $str $input\n");
+
+    print "\nTo start lldb for $type, type in another window:\n";
+    print "cd $glob_mysql_test_dir && lldb -s $lldb_init_file $$exe\n";
+
+    # Indicate the exe should not be started
+    $$exe= undef;
+    return;
+}
 
 #
 # Modify the exe and args so that program is run in ddd
@@ -6435,6 +6475,8 @@ Options for debugging the product
                         test(s)
   manual-dbx            Let user manually start mysqld in dbx, before running
                         test(s)
+  manual-lldb           Let user manually start mysqld in lldb, before running 
+                        test(s)
   max-save-core         Limit the number of core files saved (to avoid filling
                         up disks for heavily crashing server). Defaults to
                         $opt_max_save_core, set to 0 for no limit. Set
diff --git a/mysql-test/r/lock_sync.result b/mysql-test/r/lock_sync.result
index 8fe94679e70e1a8893866474180d217cf13e4796..3877e70372c874a90807f53174a32978f02a186a 100644
--- a/mysql-test/r/lock_sync.result
+++ b/mysql-test/r/lock_sync.result
@@ -773,3 +773,54 @@ Warning	1356	View 'test.v1' references invalid table(s) or column(s) or function
 SET DEBUG_SYNC= 'RESET';
 DROP VIEW v1;
 DROP TABLE t1;
+#
+# Bug#19070633 - POSSIBLE ACCESS TO FREED MEMORY IN IS_FREE_LOCK() AND IS_USED_LOCK().
+#
+# Verifying issue for IS_FREE_LOCK() function.
+SELECT GET_LOCK("lock_19070633", 600);
+GET_LOCK("lock_19070633", 600)
+1
+connect  con1, localhost, root,,;
+# Waiting after getting user level lock info and releasing mutex.
+SET DEBUG_SYNC= 'after_getting_user_level_lock_info SIGNAL parked WAIT_FOR go';
+# Sending: SELECT IS_FREE_LOCK("lock_19070633");
+SELECT IS_FREE_LOCK("lock_19070633");
+connection default;
+SET DEBUG_SYNC= 'now WAIT_FOR parked';
+SELECT RELEASE_LOCK("lock_19070633");
+RELEASE_LOCK("lock_19070633")
+1
+# Signaling connection con1 after releasing the lock.
+# Without fix, accessing user level lock info in con1 would result in
+# crash or valgrind issue invalid read is reported.
+SET DEBUG_SYNC= 'now SIGNAL go';
+connection con1;
+# Reaping: SELECT IS_FREE_LOCK("lock_19070633");
+IS_FREE_LOCK("lock_19070633")
+0
+connection default;
+# Verifying issue for IS_USED_LOCK() function.
+SELECT GET_LOCK("lock_19070633", 600);
+GET_LOCK("lock_19070633", 600)
+1
+connection con1;
+# Waiting after getting user level lock info and releasing mutex.
+SET DEBUG_SYNC= 'after_getting_user_level_lock_info SIGNAL parked WAIT_FOR go';
+# Sending: SELECT IS_USED_LOCK("lock_19070633");
+SELECT IS_USED_LOCK("lock_19070633");
+connection default;
+SET DEBUG_SYNC= 'now WAIT_FOR parked';
+SELECT RELEASE_LOCK("lock_19070633");
+RELEASE_LOCK("lock_19070633")
+1
+# Signaling connection con1 after releasing the lock.
+# Without fix, accessing user level lock info in con1 would result in
+# crash or valgrind issue invalid read is reported.
+SET DEBUG_SYNC= 'now SIGNAL go';
+connection con1;
+# Reaping: SELECT IS_USED_LOCK("lock_19070633");
+IS_USED_LOCK("lock_19070633")
+#
+connection default;
+SET DEBUG_SYNC= 'RESET';
+disconnect con1;
diff --git a/mysql-test/r/windows.result b/mysql-test/r/windows.result
index d0cdd858d4aa377365c4ddde4bc465ca31003d0c..05e4600f4b7d10562b3e53aea2542faa094ae463 100644
--- a/mysql-test/r/windows.result
+++ b/mysql-test/r/windows.result
@@ -60,3 +60,8 @@ SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
 WHERE VARIABLE_NAME = 'socket';
 VARIABLE_NAME
 SOCKET
+#
+# Bug#16581605: REPLACE.EXE UTILITY IS BROKEN IN 5.5
+#
+xyz
+def
diff --git a/mysql-test/suite/binlog/r/binlog_switch_inside_trans.result b/mysql-test/suite/binlog/r/binlog_switch_inside_trans.result
index 48b6dfa61d959d9d602977202f7c86955b21cb19..0819d4e778f834b87fab15bace78c167a148f465 100644
--- a/mysql-test/suite/binlog/r/binlog_switch_inside_trans.result
+++ b/mysql-test/suite/binlog/r/binlog_switch_inside_trans.result
@@ -1,6 +1,5 @@
 set @save_binlog_format= @@global.binlog_format;
 set @save_binlog_dirct= @@global.binlog_direct_non_transactional_updates;
-set @save_sql_log_bin= @@global.sql_log_bin;
 create table t1 (a int) engine= myisam;
 create table t2 (a int) engine= innodb;
 SELECT @@session.binlog_format;
@@ -129,7 +128,7 @@ commit;
 begin;
 insert into t2 values (5);
 # Test that the global variable 'binlog_format' and
-# 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
+# 'binlog_direct_non_transactional_updates' are
 # writable inside a transaction.
 # Current session values are ROW, FALSE, TRUE respectively.
 SELECT @@global.binlog_format;
@@ -137,20 +136,15 @@ SELECT @@global.binlog_format;
 ROW
 set @@global.binlog_format= statement;
 set @@global.binlog_direct_non_transactional_updates= TRUE;
-set @@global.sql_log_bin= FALSE;
 SELECT @@global.binlog_format;
 @@global.binlog_format
 STATEMENT
 SELECT @@global.binlog_direct_non_transactional_updates;
 @@global.binlog_direct_non_transactional_updates
 1
-SELECT @@global.sql_log_bin;
-@@global.sql_log_bin
-0
 commit;
 set @@global.binlog_format= @save_binlog_format;
 set @@global.binlog_direct_non_transactional_updates= @save_binlog_dirct;
-set @@global.sql_log_bin= @save_sql_log_bin;
 create table t3(a int, b int) engine= innodb;
 create table t4(a int) engine= innodb;
 create table t5(a int) engine= innodb;
diff --git a/mysql-test/suite/binlog/t/binlog_grant.test b/mysql-test/suite/binlog/t/binlog_grant.test
index f0367b3aa793290b13ed8573f12bc856700f75e9..0c9d9a45ec9927fa491ac9a465388e8bae4d03b3 100644
--- a/mysql-test/suite/binlog/t/binlog_grant.test
+++ b/mysql-test/suite/binlog/t/binlog_grant.test
@@ -15,7 +15,7 @@ show grants for mysqltest_1@localhost;
 connect (plain,localhost,mysqltest_1,,test);
 connect (root,localhost,root,,test);
 
-# Testing setting both session and global SQL_LOG_BIN variable both as
+# Testing setting session SQL_LOG_BIN variable both as
 # root and as plain user.
 
 --echo **** Variable SQL_LOG_BIN ****
diff --git a/mysql-test/suite/binlog/t/binlog_switch_inside_trans.test b/mysql-test/suite/binlog/t/binlog_switch_inside_trans.test
index 06c5e78bd0ea6dbe5a4dc01fb6820ff959f1185f..a93cd44fa17901376847d105117a513f709305e3 100644
--- a/mysql-test/suite/binlog/t/binlog_switch_inside_trans.test
+++ b/mysql-test/suite/binlog/t/binlog_switch_inside_trans.test
@@ -10,7 +10,6 @@ source include/have_binlog_format_row.inc;
 
 set @save_binlog_format= @@global.binlog_format;
 set @save_binlog_dirct= @@global.binlog_direct_non_transactional_updates;
-set @save_sql_log_bin= @@global.sql_log_bin;
 create table t1 (a int) engine= myisam;
 create table t2 (a int) engine= innodb;
 
@@ -117,21 +116,18 @@ commit;
 begin;
   insert into t2 values (5);
 --echo # Test that the global variable 'binlog_format' and
---echo # 'binlog_direct_non_transactional_updates' and 'sql_log_bin' are
+--echo # 'binlog_direct_non_transactional_updates' are
 --echo # writable inside a transaction.
 --echo # Current session values are ROW, FALSE, TRUE respectively.
   SELECT @@global.binlog_format;
   set @@global.binlog_format= statement;
   set @@global.binlog_direct_non_transactional_updates= TRUE;
-  set @@global.sql_log_bin= FALSE;
   SELECT @@global.binlog_format;
   SELECT @@global.binlog_direct_non_transactional_updates;
-  SELECT @@global.sql_log_bin;
 commit;
 
 set @@global.binlog_format= @save_binlog_format;
 set @@global.binlog_direct_non_transactional_updates= @save_binlog_dirct;
-set @@global.sql_log_bin= @save_sql_log_bin;
 
 create table t3(a int, b int) engine= innodb;
 create table t4(a int) engine= innodb;
diff --git a/mysql-test/suite/innodb/r/innodb_corrupt_bit.result b/mysql-test/suite/innodb/r/innodb_corrupt_bit.result
index 13b1e24a9ed47acf5957f761909ffd14d2634bfb..2ba79ced75f71c49650e00571cb05b53ab53aef7 100644
--- a/mysql-test/suite/innodb/r/innodb_corrupt_bit.result
+++ b/mysql-test/suite/innodb/r/innodb_corrupt_bit.result
@@ -79,4 +79,5 @@ z
 31
 32
 drop table corrupt_bit_test_ā;
+DROP DATABASE pad;
 SET GLOBAL innodb_change_buffering_debug = 0;
diff --git a/mysql-test/suite/innodb/r/insert_debug.result b/mysql-test/suite/innodb/r/insert_debug.result
new file mode 100644
index 0000000000000000000000000000000000000000..0d176afa116bffe943f63b14116c7d68bc0c0d13
--- /dev/null
+++ b/mysql-test/suite/innodb/r/insert_debug.result
@@ -0,0 +1,11 @@
+#
+# Bug#19904003 INNODB_LIMIT_OPTIMISTIC_INSERT_DEBUG=1
+# CAUSES INFINITE PAGE SPLIT
+#
+SET GLOBAL innodb_change_buffering_debug=1;
+SET GLOBAL innodb_limit_optimistic_insert_debug=1;
+CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE=InnoDB
+PARTITION BY HASH (c1) PARTITIONS 15;
+DROP TABLE t1;
+SET GLOBAL innodb_change_buffering_debug=0;
+SET GLOBAL innodb_limit_optimistic_insert_debug=0;
diff --git a/mysql-test/suite/innodb/r/sp_temp_table.result b/mysql-test/suite/innodb/r/sp_temp_table.result
new file mode 100644
index 0000000000000000000000000000000000000000..49a2a4aa8314e916120db8152bde645b1770e422
--- /dev/null
+++ b/mysql-test/suite/innodb/r/sp_temp_table.result
@@ -0,0 +1,253 @@
+#
+# Bug #19306524 FAILING ASSERTION WITH TEMP TABLE FOR A PROCEDURE
+# CALLED FROM A FUNCTION
+#
+call mtr.add_suppression("MySQL is trying to drop table");
+CREATE PROCEDURE cachedata(
+IN obj_id BIGINT UNSIGNED,
+IN start  DATETIME,
+IN end    DATETIME
+)
+cachedata:BEGIN
+DECLARE cache_count BIGINT;
+SET @timestamp := NOW();
+CREATE TEMPORARY TABLE IF NOT EXISTS cachedata (
+timestamp    DATETIME,
+object_id    BIGINT UNSIGNED NOT NULL,
+start        DATETIME,
+end          DATETIME,
+seqno        BIGINT AUTO_INCREMENT,
+value        FLOAT,
+PRIMARY KEY (seqno),
+INDEX (timestamp),
+INDEX (object_id, start, end)
+) ENGINE=INNODB;
+DELETE FROM cachedata WHERE
+timestamp < DATE_SUB(@timestamp, INTERVAL 15 SECOND);
+SELECT count(*) INTO cache_count FROM cachedata WHERE
+object_id = obj_id
+AND start = start
+AND end = end;
+IF cache_count > 0 THEN LEAVE cachedata;
+END IF;
+INSERT INTO cachedata (timestamp, object_id, start, end, value) VALUES
+(@timestamp, obj_id, start, end, 1234),
+(@timestamp, obj_id, start, end, 4567),
+(@timestamp, obj_id, start, end, 8901),
+(@timestamp, obj_id, start, end, 1234),
+(@timestamp, obj_id, start, end, 4567),
+(@timestamp, obj_id, start, end, 8901),
+(@timestamp, obj_id, start, end, 1234),
+(@timestamp, obj_id, start, end, 4567),
+(@timestamp, obj_id, start, end, 8901),
+(@timestamp, obj_id, start, end, 1234),
+(@timestamp, obj_id, start, end, 4567),
+(@timestamp, obj_id, start, end, 8901),
+(@timestamp, obj_id, start, end, 2345),
+(@timestamp, obj_id, start, end, 1234),
+(@timestamp, obj_id, start, end, 4567),
+(@timestamp, obj_id, start, end, 8901),
+(@timestamp, obj_id, start, end, 2345),
+(@timestamp, obj_id, start, end, 1234),
+(@timestamp, obj_id, start, end, 4567),
+(@timestamp, obj_id, start, end, 8901),
+(@timestamp, obj_id, start, end, 2345);
+END$$
+CREATE FUNCTION get_cache(
+obj_id   BIGINT UNSIGNED,
+start    DATETIME,
+end      DATETIME
+)
+RETURNS FLOAT
+READS SQL DATA
+BEGIN
+DECLARE result FLOAT;
+CALL cachedata(obj_id, start, end);
+SELECT SUM(value) INTO result FROM cachedata WHERE
+object_id = obj_id
+AND start = start
+AND end = end;
+RETURN result;
+END$$
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+SELECT get_cache(1, '2014-01-01', '2014-02-01');
+get_cache(1, '2014-01-01', '2014-02-01')
+95247
+select sleep(1);
+sleep(1)
+0
+DROP FUNCTION get_cache;
+DROP PROCEDURE cachedata;
diff --git a/mysql-test/suite/innodb/r/strict_mode.result b/mysql-test/suite/innodb/r/strict_mode.result
new file mode 100644
index 0000000000000000000000000000000000000000..7a550e105e67ed768fb9c958d2a45609f0b6a042
--- /dev/null
+++ b/mysql-test/suite/innodb/r/strict_mode.result
@@ -0,0 +1,242 @@
+#
+# Bug #17852083 PRINT A WARNING WHEN DDL HAS AN ERROR IN
+# INNODB_STRICT_MODE = 1
+#
+set innodb_strict_mode = 0;
+create table t1 (id int auto_increment primary key,
+v varchar(32),
+col1 text,
+col2 text,
+col3 text,
+col4 text,
+col5 text,
+col6 text,
+col7 text,
+col8 text,
+col9 text,
+col10 text,
+col11 text,
+col12 text,
+col13 text,
+col14 text,
+col15 text,
+col16 text,
+col17 text,
+col18 text,
+col19 text,
+col20 text,
+col21 text,
+col22 text,
+col23 text,
+col24 text,
+col25 text,
+col26 text,
+col27 text,
+col28 text,
+col29 text,
+col30 text,
+col31 text,
+col32 text,
+col33 text,
+col34 text,
+col35 text,
+col36 text,
+col37 text,
+col38 text,
+col39 text,
+col40 text,
+col41 text,
+col42 text,
+col43 text,
+col44 text,
+col45 text ,
+col46 text,
+col47 text,
+col48 text,
+col49 text,
+col50 text,
+col51 text,
+col52 text,
+col53 text,
+col54 text,
+col55 text,
+col56 text,
+col57 text,
+col58 text,
+col59 text,
+col60 text,
+col61 text,
+col62 text,
+col63 text,
+col64 text,
+col65 text,
+col66 text,
+col67 text,
+col68 text ,
+col69 text,
+col70 text,
+col71 text,
+col72 text,
+col73 text,
+col74 text,
+col75 text,
+col76 text,
+col77 text,
+col78 text,
+col79 text,
+col80 text,
+col81 text,
+col82 text,
+col83 text,
+col84 text,
+col85 text,
+col86 text,
+col87 text,
+col88 text,
+col89 text,
+col90 text,
+col91 text,
+col92 text,
+col93 text,
+col94 text,
+col95 text,
+col96 text,
+col97 text,
+col98 text,
+col99 text,
+col100 text,
+col101 text,
+col102 text,
+col103 text,
+col104 text,
+col105 text,
+col106 text,
+col107 text,
+col108 text,
+col109 text,
+col110 text,
+col111 text,
+col112 text,
+col113 text,
+col114 text,
+col115 text,
+col116 text,
+col117 text,
+col118 text,
+col119 text,
+col120 text,
+col121 text,
+col122 text,
+col123 text,
+col124 text,
+col125 text,
+col126 text ,
+col127 text,
+col128 text,
+col129 text,
+col130 text,
+col131 text,
+col132 text,
+col133 text,
+col134 text,
+col135 text,
+col136 text,
+col137 text,
+col138 text,
+col139 text,
+col140 text,
+col141 text,
+col142 text,
+col143 text,
+col144 text,
+col145 text,
+col146 text,
+col147 text ,
+col148 text,
+col149 text,
+col150 text,
+col151 text,
+col152 text,
+col153 text,
+col154 text,
+col155 text,
+col156 text,
+col157 text,
+col158 text,
+col159 text,
+col160 text,
+col161 text,
+col162 text,
+col163 text,
+col164 text,
+col165 text,
+col166 text,
+col167 text,
+col168 text,
+col169 text,
+col170 text,
+col171 text,
+col172 text ,
+col173 text,
+col174 text,
+col175 text,
+col176 text,
+col177 text,
+col178 text,
+col179 text,
+col180 text,
+col181 text,
+col182 text,
+col183 text,
+col184 text,
+col185 text,
+col186 text,
+col187 text,
+col188 text,
+col189 text,
+col190 text,
+col191 text,
+col192 text,
+col193 text,
+col194 text,
+col195 text,
+col196 text,
+col197 text,
+col198 text,
+col199 text,
+col200 text,
+col201 text,
+col202 text,
+col203 text,
+col204 text,
+col205 text,
+col206 text,
+col207 text,
+col208 text,
+col209 text,
+col210 text,
+col211 text,
+col212 text,
+col213 text,
+col214 text,
+col215 text,
+col216 text,
+col217 text,
+col218 text,
+col219 text,
+col220 text,
+col221 text,
+col222 text,
+col223 text,
+col224 text,
+col225 text,
+col226 text,
+col227 text,
+col228 text
+) ENGINE=InnoDB;
+Warnings:
+Warning	139	Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
+set innodb_strict_mode = 1;
+alter table t1 engine=InnoDB;
+ERROR 42000: Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
+drop table t1;
diff --git a/mysql-test/suite/innodb/t/innodb_corrupt_bit.test b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test
index b8d19ddfceefcfdea806341dc100df86e2b82069..753f2e29ef280f1710659377963ba5251985dab8 100644
--- a/mysql-test/suite/innodb/t/innodb_corrupt_bit.test
+++ b/mysql-test/suite/innodb/t/innodb_corrupt_bit.test
@@ -3,6 +3,11 @@
 #
 -- source include/have_innodb.inc
 
+if (`select plugin_auth_version <= "5.5.40-MariaDB-36.1" from information_schema.plugins where plugin_name='innodb'`)
+{
+  --skip Not fixed in XtraDB as of 5.5.40-MariaDB-36.1 or earlier
+}
+
 # Issues with innodb_change_buffering_debug on Windows, so the test scenario
 # cannot be created on windows
 --source include/not_windows.inc
@@ -16,14 +21,20 @@
 # It instructs InnoDB to try to evict pages from the buffer pool when
 # change buffering is possible, so that the change buffer will be used
 # whenever possible.
--- error 0,ER_UNKNOWN_SYSTEM_VARIABLE
 SET @innodb_change_buffering_debug_orig = @@innodb_change_buffering_debug;
--- error 0,ER_UNKNOWN_SYSTEM_VARIABLE
 SET GLOBAL innodb_change_buffering_debug = 1;
 
 # Turn off Unique Check to create corrupted index with dup key
 SET UNIQUE_CHECKS=0;
 
+CREATE DATABASE pad;
+let $i=345;
+while ($i)
+{
+  --eval CREATE TABLE pad.t$i (a INT PRIMARY KEY) ENGINE=InnoDB;
+  dec $i;
+}
+
 -- enable_query_log
 
 set names utf8;
@@ -119,6 +130,6 @@ select z from corrupt_bit_test_ā limit 10;
 
 # Drop table
 drop table corrupt_bit_test_ā;
+DROP DATABASE pad;
 
--- error 0, ER_UNKNOWN_SYSTEM_VARIABLE
 SET GLOBAL innodb_change_buffering_debug = 0;
diff --git a/mysql-test/suite/innodb/t/insert_debug.test b/mysql-test/suite/innodb/t/insert_debug.test
new file mode 100644
index 0000000000000000000000000000000000000000..d9096c48a8c2b3fa59dea06106cc163b9ee1fdd0
--- /dev/null
+++ b/mysql-test/suite/innodb/t/insert_debug.test
@@ -0,0 +1,22 @@
+--source include/have_innodb.inc
+--source include/have_debug.inc
+--source include/have_partition.inc
+
+if (`select plugin_auth_version <= "5.5.40-MariaDB-36.1" from information_schema.plugins where plugin_name='innodb'`)
+{
+  --skip Not fixed in XtraDB as of 5.5.40-MariaDB-36.1 or earlier
+}
+
+--echo #
+--echo # Bug#19904003 INNODB_LIMIT_OPTIMISTIC_INSERT_DEBUG=1
+--echo # CAUSES INFINITE PAGE SPLIT
+--echo #
+
+SET GLOBAL innodb_change_buffering_debug=1;
+SET GLOBAL innodb_limit_optimistic_insert_debug=1;
+CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE=InnoDB
+PARTITION BY HASH (c1) PARTITIONS 15;
+DROP TABLE t1;
+
+SET GLOBAL innodb_change_buffering_debug=0;
+SET GLOBAL innodb_limit_optimistic_insert_debug=0;
diff --git a/mysql-test/suite/innodb/t/sp_temp_table.test b/mysql-test/suite/innodb/t/sp_temp_table.test
new file mode 100644
index 0000000000000000000000000000000000000000..fca661f76e5939db542886de1c50b63ff2c962f3
--- /dev/null
+++ b/mysql-test/suite/innodb/t/sp_temp_table.test
@@ -0,0 +1,108 @@
+--source include/have_innodb.inc
+--source include/big_test.inc
+
+if (`select plugin_auth_version <= "5.5.40-MariaDB-36.1" from information_schema.plugins where plugin_name='innodb'`)
+{
+  --skip Not fixed in XtraDB as of 5.5.40-MariaDB-36.1 or earlier
+}
+
+--echo #
+--echo # Bug #19306524 FAILING ASSERTION WITH TEMP TABLE FOR A PROCEDURE
+--echo # CALLED FROM A FUNCTION
+--echo #
+
+call mtr.add_suppression("MySQL is trying to drop table");
+
+DELIMITER $$;
+CREATE PROCEDURE cachedata(
+  IN obj_id BIGINT UNSIGNED,
+  IN start  DATETIME,
+  IN end    DATETIME
+)
+
+cachedata:BEGIN
+  DECLARE cache_count BIGINT;
+
+  SET @timestamp := NOW();
+
+  CREATE TEMPORARY TABLE IF NOT EXISTS cachedata (
+    timestamp    DATETIME,
+    object_id    BIGINT UNSIGNED NOT NULL,
+    start        DATETIME,
+    end          DATETIME,
+    seqno        BIGINT AUTO_INCREMENT,
+    value        FLOAT,
+    PRIMARY KEY (seqno),
+    INDEX (timestamp),
+    INDEX (object_id, start, end)
+  ) ENGINE=INNODB;
+
+  DELETE FROM cachedata WHERE
+    timestamp < DATE_SUB(@timestamp, INTERVAL 15 SECOND);
+
+  SELECT count(*) INTO cache_count FROM cachedata WHERE
+    object_id = obj_id
+    AND start = start
+    AND end = end;
+
+  IF cache_count > 0 THEN LEAVE cachedata;
+  END IF;
+
+  INSERT INTO cachedata (timestamp, object_id, start, end, value) VALUES
+    (@timestamp, obj_id, start, end, 1234),
+    (@timestamp, obj_id, start, end, 4567),
+    (@timestamp, obj_id, start, end, 8901),
+    (@timestamp, obj_id, start, end, 1234),
+    (@timestamp, obj_id, start, end, 4567),
+    (@timestamp, obj_id, start, end, 8901),
+    (@timestamp, obj_id, start, end, 1234),
+    (@timestamp, obj_id, start, end, 4567),
+    (@timestamp, obj_id, start, end, 8901),
+    (@timestamp, obj_id, start, end, 1234),
+    (@timestamp, obj_id, start, end, 4567),
+    (@timestamp, obj_id, start, end, 8901),
+    (@timestamp, obj_id, start, end, 2345),
+    (@timestamp, obj_id, start, end, 1234),
+    (@timestamp, obj_id, start, end, 4567),
+    (@timestamp, obj_id, start, end, 8901),
+    (@timestamp, obj_id, start, end, 2345),
+    (@timestamp, obj_id, start, end, 1234),
+    (@timestamp, obj_id, start, end, 4567),
+    (@timestamp, obj_id, start, end, 8901),
+    (@timestamp, obj_id, start, end, 2345);
+
+END$$
+
+
+CREATE FUNCTION get_cache(
+  obj_id   BIGINT UNSIGNED,
+  start    DATETIME,
+  end      DATETIME
+)
+  RETURNS FLOAT
+  READS SQL DATA
+BEGIN
+  DECLARE result FLOAT;
+
+  CALL cachedata(obj_id, start, end);
+
+  SELECT SUM(value) INTO result FROM cachedata WHERE
+    object_id = obj_id
+    AND start = start
+    AND end = end;
+
+  RETURN result;
+END$$
+
+DELIMITER ;$$
+
+let $i = 30;
+while ($i)
+{
+ SELECT get_cache(1, '2014-01-01', '2014-02-01');
+ select sleep(1);
+ dec $i;
+}
+
+DROP FUNCTION get_cache;
+DROP PROCEDURE cachedata;
diff --git a/mysql-test/suite/innodb/t/strict_mode.test b/mysql-test/suite/innodb/t/strict_mode.test
new file mode 100644
index 0000000000000000000000000000000000000000..9b115091f8482e99c27be37edaee9108f65b1463
--- /dev/null
+++ b/mysql-test/suite/innodb/t/strict_mode.test
@@ -0,0 +1,251 @@
+--source include/have_innodb.inc
+
+if (`select plugin_auth_version <= "5.5.40-MariaDB-36.1" from information_schema.plugins where plugin_name='innodb'`)
+{
+  --skip Not fixed in XtraDB as of 5.5.40-MariaDB-36.1 or earlier
+}
+
+--echo #
+--echo # Bug #17852083 PRINT A WARNING WHEN DDL HAS AN ERROR IN
+--echo # INNODB_STRICT_MODE = 1
+--echo #
+
+set innodb_strict_mode = 0;
+
+create table t1 (id int auto_increment primary key,
+v varchar(32),
+col1 text,
+col2 text,
+col3 text,
+col4 text,
+col5 text,
+col6 text,
+col7 text,
+col8 text,
+col9 text,
+col10 text,
+col11 text,
+col12 text,
+col13 text,
+col14 text,
+col15 text,
+col16 text,
+col17 text,
+col18 text,
+col19 text,
+col20 text,
+col21 text,
+col22 text,
+col23 text,
+col24 text,
+col25 text,
+col26 text,
+col27 text,
+col28 text,
+col29 text,
+col30 text,
+col31 text,
+col32 text,
+col33 text,
+col34 text,
+col35 text,
+col36 text,
+col37 text,
+col38 text,
+col39 text,
+col40 text,
+col41 text,
+col42 text,
+col43 text,
+col44 text,
+col45 text ,
+col46 text,
+col47 text,
+col48 text,
+col49 text,
+col50 text,
+col51 text,
+col52 text,
+col53 text,
+col54 text,
+col55 text,
+col56 text,
+col57 text,
+col58 text,
+col59 text,
+col60 text,
+col61 text,
+col62 text,
+col63 text,
+col64 text,
+col65 text,
+col66 text,
+col67 text,
+col68 text ,
+col69 text,
+col70 text,
+col71 text,
+col72 text,
+col73 text,
+col74 text,
+col75 text,
+col76 text,
+col77 text,
+col78 text,
+col79 text,
+col80 text,
+col81 text,
+col82 text,
+col83 text,
+col84 text,
+col85 text,
+col86 text,
+col87 text,
+col88 text,
+col89 text,
+col90 text,
+col91 text,
+col92 text,
+col93 text,
+col94 text,
+col95 text,
+col96 text,
+col97 text,
+col98 text,
+col99 text,
+col100 text,
+col101 text,
+col102 text,
+col103 text,
+col104 text,
+col105 text,
+col106 text,
+col107 text,
+col108 text,
+col109 text,
+col110 text,
+col111 text,
+col112 text,
+col113 text,
+col114 text,
+col115 text,
+col116 text,
+col117 text,
+col118 text,
+col119 text,
+col120 text,
+col121 text,
+col122 text,
+col123 text,
+col124 text,
+col125 text,
+col126 text ,
+col127 text,
+col128 text,
+col129 text,
+col130 text,
+col131 text,
+col132 text,
+col133 text,
+col134 text,
+col135 text,
+col136 text,
+col137 text,
+col138 text,
+col139 text,
+col140 text,
+col141 text,
+col142 text,
+col143 text,
+col144 text,
+col145 text,
+col146 text,
+col147 text ,
+col148 text,
+col149 text,
+col150 text,
+col151 text,
+col152 text,
+col153 text,
+col154 text,
+col155 text,
+col156 text,
+col157 text,
+col158 text,
+col159 text,
+col160 text,
+col161 text,
+col162 text,
+col163 text,
+col164 text,
+col165 text,
+col166 text,
+col167 text,
+col168 text,
+col169 text,
+col170 text,
+col171 text,
+col172 text ,
+col173 text,
+col174 text,
+col175 text,
+col176 text,
+col177 text,
+col178 text,
+col179 text,
+col180 text,
+col181 text,
+col182 text,
+col183 text,
+col184 text,
+col185 text,
+col186 text,
+col187 text,
+col188 text,
+col189 text,
+col190 text,
+col191 text,
+col192 text,
+col193 text,
+col194 text,
+col195 text,
+col196 text,
+col197 text,
+col198 text,
+col199 text,
+col200 text,
+col201 text,
+col202 text,
+col203 text,
+col204 text,
+col205 text,
+col206 text,
+col207 text,
+col208 text,
+col209 text,
+col210 text,
+col211 text,
+col212 text,
+col213 text,
+col214 text,
+col215 text,
+col216 text,
+col217 text,
+col218 text,
+col219 text,
+col220 text,
+col221 text,
+col222 text,
+col223 text,
+col224 text,
+col225 text,
+col226 text,
+col227 text,
+col228 text
+) ENGINE=InnoDB;
+
+set innodb_strict_mode = 1;
+--error ER_TOO_BIG_ROWSIZE
+alter table t1 engine=InnoDB;
+
+drop table t1;
diff --git a/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result b/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result
index 5e8fe4e02f76c7d513fcc87bdd4f3ad3350ad7bd..909c434340c7e87cdca952b1612e1c417a47c6a5 100644
--- a/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result
+++ b/mysql-test/suite/sys_vars/r/sql_log_bin_basic.result
@@ -57,11 +57,16 @@ ERROR 42000: Variable 'sql_log_bin' can't be set to the value of '
 SET @@session.sql_log_bin = NO;
 ERROR 42000: Variable 'sql_log_bin' can't be set to the value of 'NO'
 '#-------------------FN_DYNVARS_156_05----------------------------#'
+SELECT @@global.sql_log_bin;
+@@global.sql_log_bin
+1
 SET @@global.sql_log_bin = 0;
+ERROR HY000: Variable 'sql_log_bin' is a SESSION variable
 SELECT @@global.sql_log_bin;
 @@global.sql_log_bin
-0
+1
 SET @@global.sql_log_bin = 1;
+ERROR HY000: Variable 'sql_log_bin' is a SESSION variable
 '#----------------------FN_DYNVARS_156_06------------------------#'
 SELECT count(VARIABLE_VALUE) FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='sql_log_bin';
 count(VARIABLE_VALUE)
diff --git a/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test b/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test
index 153a0be0b8f30dd115230747c8b0852e635b49c6..5f5e392086242755e88a7403fd2bb7a16eeba416 100644
--- a/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test
+++ b/mysql-test/suite/sys_vars/t/sql_log_bin_basic.test
@@ -109,11 +109,15 @@ SET @@session.sql_log_bin = NO;
 
 --echo '#-------------------FN_DYNVARS_156_05----------------------------#'
 ########################################################################### 
-#       Test if accessing global sql_log_bin gives error                  #
+#       Test if setting global sql_log_bin gives error,                   #
+#       and there is no error on reading it.                              #
 ########################################################################### 
 
+SELECT @@global.sql_log_bin;
+--Error ER_INCORRECT_GLOBAL_LOCAL_VAR
 SET @@global.sql_log_bin = 0;
 SELECT @@global.sql_log_bin;
+--Error ER_INCORRECT_GLOBAL_LOCAL_VAR
 SET @@global.sql_log_bin = 1;
 
 --echo '#----------------------FN_DYNVARS_156_06------------------------#'
diff --git a/mysql-test/t/lock_sync.test b/mysql-test/t/lock_sync.test
index d5ad7becd7de39cb7c48f038c4cff4ecd650faa0..bcb78b5b600c0c24cf1f614238f720a444602610 100644
--- a/mysql-test/t/lock_sync.test
+++ b/mysql-test/t/lock_sync.test
@@ -1136,6 +1136,61 @@ DROP TABLE t1;
 disconnect con1;
 disconnect con2;
 
+--echo #
+--echo # Bug#19070633 - POSSIBLE ACCESS TO FREED MEMORY IN IS_FREE_LOCK() AND IS_USED_LOCK().
+--echo #
+
+--enable_connect_log
+
+--echo # Verifying issue for IS_FREE_LOCK() function.
+SELECT GET_LOCK("lock_19070633", 600);
+
+connect (con1, localhost, root,,);
+--echo # Waiting after getting user level lock info and releasing mutex.
+SET DEBUG_SYNC= 'after_getting_user_level_lock_info SIGNAL parked WAIT_FOR go';
+--echo # Sending: SELECT IS_FREE_LOCK("lock_19070633");
+send SELECT IS_FREE_LOCK("lock_19070633");
+
+connection default;
+SET DEBUG_SYNC= 'now WAIT_FOR parked';
+SELECT RELEASE_LOCK("lock_19070633");
+--echo # Signaling connection con1 after releasing the lock.
+--echo # Without fix, accessing user level lock info in con1 would result in
+--echo # crash or valgrind issue invalid read is reported.
+SET DEBUG_SYNC= 'now SIGNAL go';
+
+connection con1;
+--echo # Reaping: SELECT IS_FREE_LOCK("lock_19070633");
+--reap
+
+connection default;
+--echo # Verifying issue for IS_USED_LOCK() function.
+SELECT GET_LOCK("lock_19070633", 600);
+
+connection con1;
+--echo # Waiting after getting user level lock info and releasing mutex.
+SET DEBUG_SYNC= 'after_getting_user_level_lock_info SIGNAL parked WAIT_FOR go';
+--echo # Sending: SELECT IS_USED_LOCK("lock_19070633");
+send SELECT IS_USED_LOCK("lock_19070633");
+
+connection default;
+SET DEBUG_SYNC= 'now WAIT_FOR parked';
+SELECT RELEASE_LOCK("lock_19070633");
+--echo # Signaling connection con1 after releasing the lock.
+--echo # Without fix, accessing user level lock info in con1 would result in
+--echo # crash or valgrind issue invalid read is reported.
+SET DEBUG_SYNC= 'now SIGNAL go';
+
+connection con1;
+--echo # Reaping: SELECT IS_USED_LOCK("lock_19070633");
+--replace_column 1 #
+--reap
+
+connection default;
+SET DEBUG_SYNC= 'RESET';
+disconnect con1;
+
+--disable_connect_log
 
 # Check that all connections opened by test cases in this file are really
 # gone so execution of other tests won't be affected by their presence.
diff --git a/mysql-test/t/windows.test b/mysql-test/t/windows.test
index b7d31948d2318de4715314e5c654d883ea4db97a..617daba6b8ef20e2b840ef7c0e381d1552d6382d 100644
--- a/mysql-test/t/windows.test
+++ b/mysql-test/t/windows.test
@@ -98,3 +98,19 @@ deallocate prepare abc;
 
 SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
   WHERE VARIABLE_NAME = 'socket';
+
+--echo #
+--echo # Bug#16581605: REPLACE.EXE UTILITY IS BROKEN IN 5.5
+--echo #
+
+# Creating a temporary text file.
+--write_file $MYSQL_TMP_DIR/bug16581605.txt
+abc
+def
+EOF
+
+#REPLACE.EXE UTILITY will work fine after the fix.
+--exec $REPLACE abc xyz < $MYSQL_TMP_DIR/bug16581605.txt
+
+#Cleanup
+remove_file $MYSQL_TMP_DIR/bug16581605.txt;
diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c
index 6674a5d394df3a9730c3093bcdd9469373c8b612..c761064dd9678f12d0717f427aaceb5a4831ead3 100644
--- a/mysys/my_wincond.c
+++ b/mysys/my_wincond.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
@@ -328,26 +328,4 @@ int pthread_attr_destroy(pthread_attr_t *connect_att)
   return 0;
 }
 
-/****************************************************************************
-** Fix localtime_r() to be a bit safer
-****************************************************************************/
-
-struct tm *localtime_r(const time_t *timep,struct tm *tmp)
-{
-  if (*timep == (time_t) -1)			/* This will crash win32 */
-  {
-    bzero(tmp,sizeof(*tmp));
-  }
-  else
-  {
-    struct tm *res=localtime(timep);
-    if (!res)                                   /* Wrong date */
-    {
-      bzero(tmp,sizeof(*tmp));                  /* Keep things safe */
-      return 0;
-    }
-    *tmp= *res;
-  }
-  return tmp;
-}
 #endif /* __WIN__ */
diff --git a/packaging/rpm-oel/mysql-systemd-start b/packaging/rpm-oel/mysql-systemd-start
index 9cb2a25c990ec8939ce73b9786a060df2894ab22..8670f889574ef252dbbb32f9470c747d0e75d6fa 100644
--- a/packaging/rpm-oel/mysql-systemd-start
+++ b/packaging/rpm-oel/mysql-systemd-start
@@ -8,10 +8,19 @@
 # post mode :  ping server until answer is received
 # 
 
+get_option () {
+    local section=$1
+    local option=$2
+    local default=$3
+    ret=$(/usr/bin/my_print_defaults $section | grep '^--'${option}'=' | cut -d= -f2-)
+    [ -z $ret ] && ret=$default
+    echo $ret
+}
+
 install_db () {    
     # Note: something different than datadir=/var/lib/mysql requires SELinux policy changes (in enforcing mode)
-    datadir=$(/usr/bin/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p')
-    
+    datadir=$(get_option mysqld datadir "/var/lib/mysql")
+
     # Restore log, dir, perms and SELinux contexts
     [ -d "$datadir" ] || install -d -m 0755 -omysql -gmysql "$datadir" || exit 1
     log=/var/log/mysqld.log
@@ -35,9 +44,16 @@ pinger () {
     # Wait for ping to answer to signal startup completed,
     # might take a while in case of e.g. crash recovery
     # MySQL systemd service will timeout script if no answer
+    datadir=$(get_option mysqld datadir "/var/lib/mysql")
+    socket=$(get_option  mysqld socket "$datadir/mysql.sock")
+    case $socket in
+        /*) adminsocket="$socket" ;;
+        *) adminsocket="$datadir/$socket" ;;
+    esac
+
     while /bin/true ; do
         sleep 1
-        mysqladmin ping >/dev/null 2>&1 && break
+        mysqladmin --no-defaults --socket="$adminsocket" --user=UNKNOWN_MYSQL_USER ping >/dev/null 2>&1 && break
     done
     exit 0
 }
diff --git a/packaging/rpm-oel/mysql.init b/packaging/rpm-oel/mysql.init
index d6f8f023850f122e898c21ab9b084507eec7e2c0..79c8a8daa7d89b4b841dfc34889af1ecf6ab0505 100644
--- a/packaging/rpm-oel/mysql.init
+++ b/packaging/rpm-oel/mysql.init
@@ -50,11 +50,15 @@ errlogfile="$result"
 get_mysql_option mysqld_safe pid-file "/var/run/mysqld/mysqld.pid"
 mypidfile="$result"
 
+case $socketfile in
+    /*) adminsocket="$socketfile" ;;
+     *) adminsocket="$datadir/$socketfile" ;;
+esac
 
 start(){
     [ -x $exec ] || exit 5
     # check to see if it's already running
-    RESPONSE=`/usr/bin/mysqladmin --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1`
+    RESPONSE=$(/usr/bin/mysqladmin --no-defaults --socket="$adminsocket" --user=UNKNOWN_MYSQL_USER ping 2>&1)
     if [ $? = 0 ]; then
 	# already running, do nothing
 	action $"Starting $prog: " /bin/true
@@ -107,7 +111,7 @@ start(){
 	ret=0
 	TIMEOUT="$STARTTIMEOUT"
 	while [ $TIMEOUT -gt 0 ]; do
-	    RESPONSE=`/usr/bin/mysqladmin --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1` && break
+	    RESPONSE=$(/usr/bin/mysqladmin --no-defaults --socket="$adminsocket" --user=UNKNOWN_MYSQL_USER ping 2>&1) && break
 	    echo "$RESPONSE" | grep -q "Access denied for user" && break
 	    if ! /bin/kill -0 $safe_pid 2>/dev/null; then
 		echo "MySQL Daemon failed to start."
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index 7fb5780268520b7edcc2bc556121b901a58bdb4b..862769d5be71e93ed666a30651e455ab3481fbee 100644
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -89,17 +89,10 @@ IF(MALLOC_LIB)
 ENDIF()
 
 IF(CMAKE_GENERATOR MATCHES "Makefiles")
-  # Strip maintainer mode options if necessary
-  STRING(REPLACE "${MY_MAINTAINER_C_WARNINGS}" "" CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELWITHDEBINFO}")
-  STRING(REPLACE "${MY_MAINTAINER_CXX_WARNINGS}" "" CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
   FOREACH(ARCH ${CMAKE_OSX_ARCHITECTURES})
     SET(CFLAGS   "${CFLAGS} -arch ${ARCH}")
     SET(CXXFLAGS "${CXXFLAGS} -arch ${ARCH}")
   ENDFOREACH()
-ELSE()
-  # Strip maintainer mode options if necessary
-  STRING(REPLACE "${MY_MAINTAINER_C_WARNINGS}" "" CFLAGS "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
-  STRING(REPLACE "${MY_MAINTAINER_CXX_WARNINGS}" "" CXXFLAGS "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
 ENDIF()
 
 IF(UNIX)
diff --git a/scripts/mysql_setpermission.sh b/scripts/mysql_setpermission.sh
index f23011a5ae6418ce787f1e8405495891f47d4ecb..48f0b09b566d324dae63be85e36f9b31a352fc49 100644
--- a/scripts/mysql_setpermission.sh
+++ b/scripts/mysql_setpermission.sh
@@ -264,13 +264,13 @@ sub addall {
   foreach $host (@hosts) {
     # user privileges: SELECT
     if (($todo == 2) || ($todo == 3)) {
-      $sth = $dbh->do("GRANT SELECT ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
+      $sth = $dbh->do("GRANT SELECT ON $db.* TO \'$user\'@\'$host\' IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
     } elsif ($todo == 4) {
       # user privileges: SELECT,INSERT,UPDATE,DELETE
-      $sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
+      $sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE ON $db.* TO \'$user\'@\'$host\' IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
     } elsif ($todo == 5) {
       # user privileges: SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES
-      $sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
+      $sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES ON $db.* TO \'$user\'@\'$host\' IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
     } elsif ($todo == 6) {
        # all privileges
        $sth = $dbh->do("GRANT ALL ON $db.* TO \'$user\'\@\'$host\' IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
diff --git a/sql/handler.h b/sql/handler.h
index d7b92003083ef2c97e8bfb870024a239ba03f984..5c902e604e9c786cb9ee6c266cdcc7f63f504647 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -1079,6 +1079,9 @@ inline LEX_STRING *hton_name(const handlerton *hton)
 #define HTON_NO_PARTITION            (1 << 8) //You can not partition these tables
 #define HTON_EXTENDED_KEYS           (1 << 9) //supports extended keys
 
+// MySQL compatibility. Unused.
+#define HTON_SUPPORTS_FOREIGN_KEYS   (1 << 0) //Foreign key constraint supported.
+
 class Ha_trx_info;
 
 struct THD_TRANS
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 52693b1961aab3f77f166e25e51a12696e5f68c3..93eafdfa9386ee88d4f93488d7c593972c2486a1 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -6545,21 +6545,24 @@ longlong Item_func_is_free_lock::val_int()
   DBUG_ASSERT(fixed == 1);
   String *res=args[0]->val_str(&value);
   User_level_lock *ull;
+  longlong ret_val= 0LL;
 
   null_value=0;
   if (!res || !res->length())
   {
     null_value=1;
-    return 0;
+    return ret_val;
   }
   
   mysql_mutex_lock(&LOCK_user_locks);
   ull= (User_level_lock *) my_hash_search(&hash_user_locks, (uchar*) res->ptr(),
                                           (size_t) res->length());
-  mysql_mutex_unlock(&LOCK_user_locks);
   if (!ull || !ull->locked)
-    return 1;
-  return 0;
+    ret_val= 1;
+  mysql_mutex_unlock(&LOCK_user_locks);
+  DEBUG_SYNC(current_thd, "after_getting_user_level_lock_info");
+
+  return ret_val;
 }
 
 longlong Item_func_is_used_lock::val_int()
@@ -6567,6 +6570,7 @@ longlong Item_func_is_used_lock::val_int()
   DBUG_ASSERT(fixed == 1);
   String *res=args[0]->val_str(&value);
   User_level_lock *ull;
+  my_thread_id thread_id= 0UL;
 
   null_value=1;
   if (!res || !res->length())
@@ -6575,12 +6579,15 @@ longlong Item_func_is_used_lock::val_int()
   mysql_mutex_lock(&LOCK_user_locks);
   ull= (User_level_lock *) my_hash_search(&hash_user_locks, (uchar*) res->ptr(),
                                           (size_t) res->length());
+  if ((ull != NULL) && ull->locked)
+  {
+    null_value= 0;
+    thread_id= ull->thread_id;
+  }
   mysql_mutex_unlock(&LOCK_user_locks);
-  if (!ull || !ull->locked)
-    return 0;
+  DEBUG_SYNC(current_thd, "after_getting_user_level_lock_info");
 
-  null_value=0;
-  return ull->thread_id;
+  return thread_id;
 }
 
 
diff --git a/sql/item_func.h b/sql/item_func.h
index ab0ae5f0bda356b5b7d338cb03fdae71c647f9cd..4b11238c10db03a716fc6a38a3d458cf1c2fcd81 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -1,7 +1,7 @@
 #ifndef ITEM_FUNC_INCLUDED
 #define ITEM_FUNC_INCLUDED
-/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
-   Copyright (c) 2009, 2014, SkySQL Ab.
+/* Copyright (c) 2000, 2014, Oracle and/or its affiliates.
+   Copyright (c) 2009, 2014, MariaDB
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -279,7 +279,8 @@ class Item_func :public Item_result_field
   inline longlong check_integer_overflow(longlong value, bool val_unsigned)
   {
     if ((unsigned_flag && !val_unsigned && value < 0) ||
-        (!unsigned_flag && val_unsigned && (ulonglong) value > LONGLONG_MAX))
+        (!unsigned_flag && val_unsigned &&
+         (ulonglong) value > (ulonglong) LONGLONG_MAX))
       return raise_integer_overflow();
     return value;
   }
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 6b21a303a5035b16251edfd268ffc7a83344fa64..d04ac1e1a44cc895fe106308459ef35ccaaa46bb 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1583,7 +1583,7 @@ Log_event* Log_event::read_log_event(const char* buf, uint event_len,
       ev = new Execute_load_log_event(buf, event_len, description_event);
       break;
     case START_EVENT_V3: /* this is sent only by MySQL <=4.x */
-      ev = new Start_log_event_v3(buf, description_event);
+      ev = new Start_log_event_v3(buf, event_len, description_event);
       break;
     case STOP_EVENT:
       ev = new Stop_log_event(buf, description_event);
@@ -4138,11 +4138,17 @@ void Start_log_event_v3::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
   Start_log_event_v3::Start_log_event_v3()
 */
 
-Start_log_event_v3::Start_log_event_v3(const char* buf,
+Start_log_event_v3::Start_log_event_v3(const char* buf, uint event_len,
                                        const Format_description_log_event
                                        *description_event)
-  :Log_event(buf, description_event)
+  :Log_event(buf, description_event), binlog_version(BINLOG_VERSION)
 {
+  if (event_len < (uint)description_event->common_header_len +
+      ST_COMMON_HEADER_LEN_OFFSET)
+  {
+    server_version[0]= 0;
+    return;
+  }
   buf+= description_event->common_header_len;
   binlog_version= uint2korr(buf+ST_BINLOG_VER_OFFSET);
   memcpy(server_version, buf+ST_SERVER_VER_OFFSET,
@@ -4442,9 +4448,12 @@ Format_description_log_event(const char* buf,
                              const
                              Format_description_log_event*
                              description_event)
-  :Start_log_event_v3(buf, description_event), event_type_permutation(0)
+  :Start_log_event_v3(buf, event_len, description_event),
+   common_header_len(0), post_header_len(NULL), event_type_permutation(0)
 {
   DBUG_ENTER("Format_description_log_event::Format_description_log_event(char*,...)");
+  if (!Start_log_event_v3::is_valid())
+    DBUG_VOID_RETURN; /* sanity check */
   buf+= LOG_EVENT_MINIMAL_HEADER_LEN;
   if ((common_header_len=buf[ST_COMMON_HEADER_LEN_OFFSET]) < OLD_HEADER_LEN)
     DBUG_VOID_RETURN; /* sanity check */
diff --git a/sql/log_event.h b/sql/log_event.h
index c10380618a84ba79d2b1e2b5f5f085d89bb98d22..4ae01323b4b78fd4cba759d43a198229ed689669 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -2366,14 +2366,14 @@ class Start_log_event_v3: public Log_event
   void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
 #endif
 
-  Start_log_event_v3(const char* buf,
+  Start_log_event_v3(const char* buf, uint event_len,
                      const Format_description_log_event* description_event);
   ~Start_log_event_v3() {}
   Log_event_type get_type_code() { return START_EVENT_V3;}
 #ifdef MYSQL_SERVER
   bool write(IO_CACHE* file);
 #endif
-  bool is_valid() const { return 1; }
+  bool is_valid() const { return server_version[0] != 0; }
   int get_data_size()
   {
     return START_V3_HEADER_LEN; //no variable-sized part
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index c21e7fa3e4b8526b995443bf54f83530be67ce7f..4ad3f9ab8c56aa1418751accdbbb85ebf688733f 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -5383,6 +5383,115 @@ bool check_global_access(THD *thd, ulong want_access, bool no_errors)
 #endif
 }
 
+
+/**
+  Checks foreign key's parent table access.
+
+  @param thd	       [in]	Thread handler
+  @param create_info   [in]     Create information (like MAX_ROWS, ENGINE or
+                                temporary table flag)
+  @param alter_info    [in]     Initial list of columns and indexes for the
+                                table to be created
+
+  @retval
+   false  ok.
+  @retval
+   true	  error or access denied. Error is sent to client in this case.
+*/
+bool check_fk_parent_table_access(THD *thd,
+                                  HA_CREATE_INFO *create_info,
+                                  Alter_info *alter_info)
+{
+  Key *key;
+  List_iterator<Key> key_iterator(alter_info->key_list);
+
+  while ((key= key_iterator++))
+  {
+    if (key->type == Key::FOREIGN_KEY)
+    {
+      TABLE_LIST parent_table;
+      bool is_qualified_table_name;
+      Foreign_key *fk_key= (Foreign_key *)key;
+      LEX_STRING db_name;
+      LEX_STRING table_name= { fk_key->ref_table->table.str,
+                               fk_key->ref_table->table.length };
+      const ulong privileges= (SELECT_ACL | INSERT_ACL | UPDATE_ACL |
+                               DELETE_ACL | REFERENCES_ACL);
+
+      // Check if tablename is valid or not.
+      DBUG_ASSERT(table_name.str != NULL);
+      if (check_table_name(table_name.str, table_name.length, false))
+      {
+        my_error(ER_WRONG_TABLE_NAME, MYF(0), table_name.str);
+        return true;
+      }
+
+      if (fk_key->ref_table->db.str)
+      {
+        is_qualified_table_name= true;
+        db_name.str= (char *) thd->memdup(fk_key->ref_table->db.str,
+                                          fk_key->ref_table->db.length+1);
+        db_name.length= fk_key->ref_table->db.length;
+
+        // Check if database name is valid or not.
+        if (fk_key->ref_table->db.str && check_db_name(&db_name))
+        {
+          my_error(ER_WRONG_DB_NAME, MYF(0), db_name.str);
+          return true;
+        }
+      }
+      else if (thd->lex->copy_db_to(&db_name.str, &db_name.length))
+        return true;
+      else
+        is_qualified_table_name= false;
+
+      // if lower_case_table_names is set then convert tablename to lower case.
+      if (lower_case_table_names)
+      {
+        table_name.str= (char *) thd->memdup(fk_key->ref_table->table.str,
+                                             fk_key->ref_table->table.length+1);
+        table_name.length= my_casedn_str(files_charset_info, table_name.str);
+      }
+
+      parent_table.init_one_table(db_name.str, db_name.length,
+                                  table_name.str, table_name.length,
+                                  table_name.str, TL_IGNORE);
+
+      /*
+       Check if user has any of the "privileges" at table level on
+       "parent_table".
+       Having privilege on any of the parent_table column is not
+       enough so checking whether user has any of the "privileges"
+       at table level only here.
+      */
+      if (check_some_access(thd, privileges, &parent_table) ||
+          parent_table.grant.want_privilege)
+      {
+        if (is_qualified_table_name)
+        {
+          const size_t qualified_table_name_len= NAME_LEN + 1 + NAME_LEN + 1;
+          char *qualified_table_name= (char *) thd->alloc(qualified_table_name_len);
+
+          my_snprintf(qualified_table_name, qualified_table_name_len, "%s.%s",
+                      db_name.str, table_name.str);
+          table_name.str= qualified_table_name;
+        }
+
+        my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
+                 "REFERENCES",
+                 thd->security_ctx->priv_user,
+                 thd->security_ctx->host_or_ip,
+                 table_name.str);
+
+        return true;
+      }
+    }
+  }
+
+  return false;
+}
+
+
 /****************************************************************************
 	Check stack size; Send error if there isn't enough stack to continue
 ****************************************************************************/
@@ -7347,8 +7456,11 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
     if (check_table_access(thd, SELECT_ACL, tables, FALSE, UINT_MAX, FALSE))
       goto err;
   }
-  error= FALSE;
 
+  if (check_fk_parent_table_access(thd, &lex->create_info, &lex->alter_info))
+    goto err;
+
+  error= FALSE;
 err:
   DBUG_RETURN(error);
 }
diff --git a/sql/sql_parse.h b/sql/sql_parse.h
index d1d6458d22c0c70946280a899516dfab146eb3c7..60d5925c5731421fccab01f006ab362cb0836434 100644
--- a/sql/sql_parse.h
+++ b/sql/sql_parse.h
@@ -45,6 +45,9 @@ bool delete_precheck(THD *thd, TABLE_LIST *tables);
 bool insert_precheck(THD *thd, TABLE_LIST *tables);
 bool create_table_precheck(THD *thd, TABLE_LIST *tables,
                            TABLE_LIST *create_table);
+bool check_fk_parent_table_access(THD *thd,
+                                  HA_CREATE_INFO *create_info,
+                                  Alter_info *alter_info);
 
 bool parse_sql(THD *thd,
                Parser_state *parser_state,
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 9a0a64151d5a4c23977aa4ecda77fd38d7ad817c..77dbc7658099a846d233e079381e8b8ca2cdcf44 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -6245,6 +6245,18 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
     goto err;
   }
 
+  /*
+   If foreign key is added then check permission to access parent table.
+
+   In function "check_fk_parent_table_access", create_info->db_type is used
+   to identify whether engine supports FK constraint or not. Since
+   create_info->db_type is set here, check to parent table access is delayed
+   till this point for the alter operation.
+  */
+  if ((alter_info->flags & ALTER_FOREIGN_KEY) &&
+      check_fk_parent_table_access(thd, create_info, alter_info))
+    goto err;
+
   /*
     If this is an ALTER TABLE and no explicit row type specified reuse
     the table's row type.
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 5c2cabf7c2e8674cc78363dbc98dfcc9942a9c8e..7cad362f6f21e5857825722a497f7a774864f100 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -2650,13 +2650,13 @@ static Sys_var_bit Sys_log_off(
 static bool fix_sql_log_bin_after_update(sys_var *self, THD *thd,
                                          enum_var_type type)
 {
-  if (type == OPT_SESSION)
-  {
-    if (thd->variables.sql_log_bin)
-      thd->variables.option_bits |= OPTION_BIN_LOG;
-    else
-      thd->variables.option_bits &= ~OPTION_BIN_LOG;
-  }
+  DBUG_ASSERT(type == OPT_SESSION);
+
+  if (thd->variables.sql_log_bin)
+    thd->variables.option_bits |= OPTION_BIN_LOG;
+  else
+    thd->variables.option_bits &= ~OPTION_BIN_LOG;
+
   return FALSE;
 }
 
@@ -2678,7 +2678,10 @@ static bool check_sql_log_bin(sys_var *self, THD *thd, set_var *var)
     return TRUE;
 
   if (var->type == OPT_GLOBAL)
-    return FALSE;
+  {
+    my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), self->name.str, "SESSION");
+    return TRUE;
+  }
 
   if (error_if_in_trans_or_substatement(thd,
           ER_STORED_FUNCTION_PREVENTS_SWITCH_SQL_LOG_BIN,
@@ -2689,9 +2692,9 @@ static bool check_sql_log_bin(sys_var *self, THD *thd, set_var *var)
 }
 
 static Sys_var_mybool Sys_log_binlog(
-       "sql_log_bin", "sql_log_bin",
-       SESSION_VAR(sql_log_bin), NO_CMD_LINE,
-       DEFAULT(TRUE), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_sql_log_bin),
+       "sql_log_bin", "Controls whether logging to the binary log is done",
+       SESSION_VAR(sql_log_bin), NO_CMD_LINE, DEFAULT(TRUE),
+       NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_sql_log_bin),
        ON_UPDATE(fix_sql_log_bin_after_update));
 
 static Sys_var_bit Sys_sql_warnings(
diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt
index 1e1b74f82cd515e2248afb4d337e911cd4d2a577..e6a65566d665bf47cd3393a6521efeed608c31fc 100644
--- a/storage/innobase/CMakeLists.txt
+++ b/storage/innobase/CMakeLists.txt
@@ -295,6 +295,14 @@ SET(INNOBASE_SOURCES	btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c
 			ut/ut0byte.c ut/ut0dbg.c ut/ut0list.c ut/ut0mem.c ut/ut0rbt.c ut/ut0rnd.c
 			ut/ut0ut.c ut/ut0vec.c ut/ut0wqueue.c ut/ut0bh.c)
 
+# These files have unused result errors, so we skip Werror
+CHECK_C_COMPILER_FLAG("-Werror" HAVE_WERROR)
+IF(HAVE_WERROR)
+  INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake)
+  ADD_COMPILE_FLAGS(page/page0zip.c COMPILE_FLAGS "-Wno-error")
+  ADD_COMPILE_FLAGS(ut/ut0ut.c      COMPILE_FLAGS "-Wno-error")
+ENDIF()
+
 IF(WITH_INNODB)
   # Legacy option
   SET(WITH_INNOBASE_STORAGE_ENGINE TRUE)
diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c
index 0e4691658d5f8b52e9a065d28e1d1caefd6c1ed3..c298f867ae36f64b93ca1e3bf0200f33b41c7bda 100644
--- a/storage/innobase/dict/dict0dict.c
+++ b/storage/innobase/dict/dict0dict.c
@@ -42,6 +42,12 @@ UNIV_INTERN dict_index_t*	dict_ind_compact;
 UNIV_INTERN uint	ibuf_debug;
 #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
 
+/**********************************************************************
+Issue a warning that the row is too big. */
+void
+ib_warn_row_too_big(const dict_table_t*	table);
+
+
 #ifndef UNIV_HOTBACKUP
 #include "buf0buf.h"
 #include "data0type.h"
@@ -1765,11 +1771,18 @@ dict_index_add_to_cache(
 
 	new_index->n_fields = new_index->n_def;
 
-	if (strict && dict_index_too_big_for_tree(table, new_index)) {
+	if (dict_index_too_big_for_tree(table, new_index)) {
+
+		if (strict) {
 too_big:
-		dict_mem_index_free(new_index);
-		dict_mem_index_free(index);
-		return(DB_TOO_BIG_RECORD);
+			dict_mem_index_free(new_index);
+			dict_mem_index_free(index);
+			return(DB_TOO_BIG_RECORD);
+		} else {
+
+			ib_warn_row_too_big(table);
+
+		}
 	}
 
 	if (UNIV_UNLIKELY(index->type & DICT_UNIVERSAL)) {
@@ -2516,8 +2529,15 @@ dict_foreign_remove_from_cache(
 			       foreign);
 
 		rbt = foreign->referenced_table->referenced_rbt;
+
 		if (rbt != NULL) {
-			rbt_delete(rbt, foreign->id);
+			const ib_rbt_node_t*	node
+				= rbt_lookup(rbt, foreign->id);
+			dict_foreign_t*	val = *(dict_foreign_t**) node->value;
+
+			if (val == foreign) {
+				rbt_delete(rbt, foreign->id);
+			}
 		}
 	}
 
@@ -2530,7 +2550,13 @@ dict_foreign_remove_from_cache(
 		rbt = foreign->foreign_table->foreign_rbt;
 
 		if (rbt != NULL) {
-			rbt_delete(rbt, foreign->id);
+			const ib_rbt_node_t*	node
+				= rbt_lookup(rbt, foreign->id);
+			dict_foreign_t*	val = *(dict_foreign_t**) node->value;
+
+			if (val == foreign) {
+				rbt_delete(rbt, foreign->id);
+			}
 		}
 	}
 
@@ -5485,11 +5511,11 @@ dict_set_corrupted(
 
 	dict_index_copy_types(tuple, sys_index, 2);
 
-	btr_cur_search_to_nth_level(sys_index, 0, tuple, PAGE_CUR_GE,
+	btr_cur_search_to_nth_level(sys_index, 0, tuple, PAGE_CUR_LE,
 				    BTR_MODIFY_LEAF,
 				    &cursor, 0, __FILE__, __LINE__, &mtr);
 
-	if (cursor.up_match == dtuple_get_n_fields(tuple)) {
+	if (cursor.low_match == dtuple_get_n_fields(tuple)) {
 		/* UPDATE SYS_INDEXES SET TYPE=index->type
 		WHERE TABLE_ID=index->table->id AND INDEX_ID=index->id */
 		ulint	len;
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 450e89ebb87a7bd32ec43d7220c2c62847d4f43a..d58eb0689a299d520362547c4c9f813fb70d978d 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -2261,7 +2261,7 @@ innobase_init(
         innobase_hton->start_consistent_snapshot=innobase_start_trx_and_assign_read_view;
         innobase_hton->flush_logs=innobase_flush_logs;
         innobase_hton->show_status=innobase_show_status;
-        innobase_hton->flags=HTON_EXTENDED_KEYS;
+        innobase_hton->flags=HTON_EXTENDED_KEYS | HTON_SUPPORTS_FOREIGN_KEYS;
         innobase_hton->release_temporary_latches=innobase_release_temporary_latches;
 	innobase_hton->alter_table_flags = innobase_alter_table_flags;
         innobase_hton->kill_query = innobase_kill_query;
@@ -9331,6 +9331,7 @@ ha_innobase::start_stmt(
 	thr_lock_type	lock_type)
 {
 	trx_t*		trx;
+	DBUG_ENTER("ha_innobase::start_stmt");
 
 	update_thd(thd);
 
@@ -9353,6 +9354,28 @@ ha_innobase::start_stmt(
 	prebuilt->hint_need_to_fetch_extra_cols = 0;
 	reset_template(prebuilt);
 
+	if (dict_table_is_temporary(prebuilt->table)
+	    && prebuilt->mysql_has_locked
+	    && prebuilt->select_lock_type == LOCK_NONE) {
+		ulint error;
+
+		switch (thd_sql_command(thd)) {
+		case SQLCOM_INSERT:
+		case SQLCOM_UPDATE:
+		case SQLCOM_DELETE:
+			init_table_handle_for_HANDLER();
+			prebuilt->select_lock_type = LOCK_X;
+			error = row_lock_table_for_mysql(prebuilt, NULL, 1);
+
+			if (error != DB_SUCCESS) {
+				error = convert_error_code_to_mysql(
+					(int) error, 0, thd);
+				DBUG_RETURN((int) error);
+			}
+			break;
+		}
+	}
+
 	if (!prebuilt->mysql_has_locked) {
 		/* This handle is for a temporary table created inside
 		this same LOCK TABLES; since MySQL does NOT call external_lock
@@ -9385,7 +9408,7 @@ ha_innobase::start_stmt(
 
 	innobase_register_trx(ht, thd, trx);
 
-	return(0);
+	DBUG_RETURN(0);
 }
 
 /******************************************************************//**
@@ -12232,3 +12255,30 @@ innobase_convert_to_filename_charset(
 
 	return(strconvert(cs_from, from, cs_to, to, len, &errors));
 }
+
+
+/**********************************************************************
+Issue a warning that the row is too big. */
+extern "C"
+void
+ib_warn_row_too_big(const dict_table_t*	table)
+{
+	/* If prefix is true then a 768-byte prefix is stored
+	locally for BLOB fields. Refer to dict_table_get_format() */
+	const bool	prefix = ((table->flags & DICT_TF_FORMAT_MASK)
+				  >> DICT_TF_FORMAT_SHIFT) < UNIV_FORMAT_B;
+
+	const ulint	free_space = page_get_free_space_of_empty(
+		table->flags & DICT_TF_COMPACT) / 2;
+
+	THD*	thd = current_thd;
+
+	push_warning_printf(
+		thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_ERR_TO_BIG_ROW,
+		"Row size too large (> %lu). Changing some columns to TEXT"
+		" or BLOB %smay help. In current row format, BLOB prefix of"
+		" %d bytes is stored inline.", free_space
+		, prefix ? "or using ROW_FORMAT=DYNAMIC or"
+		" ROW_FORMAT=COMPRESSED ": ""
+		, prefix ? DICT_MAX_FIXED_COL_LEN : 0);
+}
diff --git a/storage/innobase/include/btr0cur.ic b/storage/innobase/include/btr0cur.ic
index 5fc4651ca138d482490e84ae745bba037c6e49ba..5d122101fab16db956e82852ff0cc78422c5a8a7 100644
--- a/storage/innobase/include/btr0cur.ic
+++ b/storage/innobase/include/btr0cur.ic
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-Copyright (c) 1994, 2012, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1994, 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 the Free Software
@@ -28,7 +28,7 @@ Created 10/16/1994 Heikki Tuuri
 
 #ifdef UNIV_DEBUG
 # define LIMIT_OPTIMISTIC_INSERT_DEBUG(NREC, CODE)\
-if (btr_cur_limit_optimistic_insert_debug\
+if (btr_cur_limit_optimistic_insert_debug > 1\
     && (NREC) >= (ulint)btr_cur_limit_optimistic_insert_debug) {\
         CODE;\
 }
diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h
index 64ece646dcceea95628f44467a348f8acd390f74..0ad3cb3bcceaeaca70ddd4b5bfd0688b76b1dd33 100644
--- a/storage/innobase/include/dict0dict.h
+++ b/storage/innobase/include/dict0dict.h
@@ -1375,6 +1375,14 @@ dict_table_init_referenced_rbt(
 /*===========================*/
 	dict_table_t*	table);	/*!< in: the table object whose
 				table->referenced_rbt will be initialized */
+/********************************************************************//**
+Check if it is a temporary table.
+@return        true if temporary table flag is set. */
+UNIV_INLINE
+ibool
+dict_table_is_temporary(
+/*====================*/
+	const dict_table_t*     table);  /*!< in: table to check */
 
 #ifndef UNIV_NONINL
 #include "dict0dict.ic"
diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic
index a63e1d16427df88b662f34b6f24fcb9c17e2467e..b65cae2a1d88e7d016398bead65847be6d1ec9b8 100644
--- a/storage/innobase/include/dict0dict.ic
+++ b/storage/innobase/include/dict0dict.ic
@@ -1004,3 +1004,15 @@ dict_table_init_referenced_rbt(
 	ut_a(table->referenced_rbt != NULL);
 	return(table->referenced_rbt);
 }
+
+/********************************************************************//**
+Check if it is a temporary table.
+@return        true if temporary table flag is set. */
+UNIV_INLINE
+ibool
+dict_table_is_temporary(
+/*====================*/
+	const dict_table_t*     table)  /*!< in: table to check */
+{
+	return(table->flags & (DICT_TF2_TEMPORARY << DICT_TF2_SHIFT));
+}
diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c
index 8555054b86fd7292e0d2b91f7127327f804a87c7..181ca96645139bfb99dff8306979633b327c756b 100644
--- a/storage/innobase/row/row0mysql.c
+++ b/storage/innobase/row/row0mysql.c
@@ -1,6 +1,6 @@
 /*****************************************************************************
 
-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 the Free Software
@@ -3089,6 +3089,9 @@ row_drop_table_for_mysql(
 	ulint		namelen;
 	ibool		locked_dictionary	= FALSE;
 	pars_info_t*    info			= NULL;
+	DBUG_ENTER("row_drop_table_for_mysql");
+
+	DBUG_PRINT("row_drop_table_for_mysql", ("table: %s", name));
 
 	ut_a(name != NULL);
 
@@ -3099,7 +3102,7 @@ row_drop_table_for_mysql(
 		      "InnoDB: Shut down mysqld and edit my.cnf so that newraw"
 		      " is replaced with raw.\n", stderr);
 
-		return(DB_ERROR);
+		DBUG_RETURN(DB_ERROR);
 	}
 
 	trx->op_info = "dropping table";
@@ -3504,7 +3507,7 @@ row_drop_table_for_mysql(
 
 	srv_wake_master_thread();
 
-	return((int) err);
+	DBUG_RETURN((int) err);
 }
 
 /*********************************************************************//**
diff --git a/storage/myisam/ftbench/ft-test-run.sh b/storage/myisam/ftbench/ft-test-run.sh
index 17b13d73d47f7cf237a89da404069e0e8ceb76c8..08e03474dac2b196d1e8e755efd5b905bcec7a9c 100755
--- a/storage/myisam/ftbench/ft-test-run.sh
+++ b/storage/myisam/ftbench/ft-test-run.sh
@@ -2,7 +2,7 @@
 
 # Copyright (c) 2003, 2005, 2006 MySQL AB
 # Use is subject to license terms
- 
+# 
 # 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
diff --git a/storage/tokudb/CMakeLists.txt b/storage/tokudb/CMakeLists.txt
index 7732ac6369c3f93e6d5809d81b38e7dba7171d78..165e63314430134bd25678f490971b53e05258c3 100644
--- a/storage/tokudb/CMakeLists.txt
+++ b/storage/tokudb/CMakeLists.txt
@@ -17,6 +17,13 @@ IF(NOT LIBJEMALLOC)
   MESSAGE(WARNING "TokuDB is enabled, but jemalloc is not. This configuration is not supported")
 ENDIF()
 
+IF (HAVE_WVLA)
+  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-vla")
+  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-vla")
+  SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-vla")
+  SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-vla")
+ENDIF()
+
 ############################################
 SET(TOKUDB_VERSION "tokudb-7.5.3")
 SET(TOKUDB_DEB_FILES "usr/lib/mysql/plugin/ha_tokudb.so\netc/mysql/conf.d/tokudb.cnf\nusr/bin/tokuftdump\nusr/share/doc/mariadb-server-5.5/README-TOKUDB\nusr/share/doc/mariadb-server-5.5/README.md" PARENT_SCOPE)
diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh
index ee95e65780b55fcb86795054cd796661452572fd..e45573a6d776a48d257042f300f0716daafe1988 100644
--- a/support-files/mysql.spec.sh
+++ b/support-files/mysql.spec.sh
@@ -499,12 +499,14 @@ mkdir debug
   # Attempt to remove any optimisation flags from the debug build
   CFLAGS=`echo " ${CFLAGS} " | \
             sed -e 's/ -O[0-9]* / /' \
+                -e 's/-Wp,-D_FORTIFY_SOURCE=2/ /' \
                 -e 's/ -unroll2 / /' \
                 -e 's/ -ip / /' \
                 -e 's/^ //' \
                 -e 's/ $//'`
   CXXFLAGS=`echo " ${CXXFLAGS} " | \
               sed -e 's/ -O[0-9]* / /' \
+                  -e 's/-Wp,-D_FORTIFY_SOURCE=2/ /' \
                   -e 's/ -unroll2 / /' \
                   -e 's/ -ip / /' \
                   -e 's/^ //' \
@@ -1250,12 +1252,12 @@ echo "====="                                     >> $STATUS_HISTORY
 * Mon Jun 11 2012 Joerg Bruehe <joerg.bruehe@oracle.com>
 
 - Make sure newly added "SPECIFIC-ULN/" directory does not disturb packaging.
-  
+
 * Wed Sep 28 2011 Joerg Bruehe <joerg.bruehe@oracle.com>
 
 - Fix duplicate mentioning of "mysql_plugin" and its manual page,
   it is better to keep alphabetic order in the files list (merging!).
-  
+
 * Wed Sep 14 2011 Joerg Bruehe <joerg.bruehe@oracle.com>
 
 - Let the RPM capabilities ("obsoletes" etc) ensure that an upgrade may replace
@@ -1288,7 +1290,7 @@ echo "====="                                     >> $STATUS_HISTORY
 * Fri Aug 19 2011 Joerg Bruehe <joerg.bruehe@oracle.com>
 
 - Null-upmerge the fix of bug#37165: This spec file is not affected.
-- Replace "/var/lib/mysql" by the spec file variable "%{mysqldatadir}".
+- Replace "/var/lib/mysql" by the spec file variable "%%{mysqldatadir}".
 
 * Fri Aug 12 2011 Daniel Fischer <daniel.fischer@oracle.com>
 
@@ -1309,13 +1311,13 @@ echo "====="                                     >> $STATUS_HISTORY
   not in an RPM upgrade.
   This affects both the "mkdir" and the call of "mysql_install_db".
 
-* Thu Feb 09 2011 Joerg Bruehe <joerg.bruehe@oracle.com>
+* Wed Feb 09 2011 Joerg Bruehe <joerg.bruehe@oracle.com>
 
 - Fix bug#56581: If an installation deviates from the default file locations
   ("datadir" and "pid-file"), the mechanism to detect a running server (on upgrade)
   should still work, and use these locations.
   The problem was that the fix for bug#27072 did not check for local settings.
-  
+
 * Mon Jan 31 2011 Joerg Bruehe <joerg.bruehe@oracle.com>
 
 - Install the new "manifest" files: "INFO_SRC" and "INFO_BIN".
@@ -1430,7 +1432,7 @@ echo "====="                                     >> $STATUS_HISTORY
 - Fix some problems with the directives around "tcmalloc" (experimental),
   remove erroneous traces of the InnoDB plugin (that is 5.1 only).
 
-* Fri Oct 06 2009 Magnus Blaudd <mvensson@mysql.com>
+* Tue Oct 06 2009 Magnus Blaudd <mvensson@mysql.com>
 
 - Removed mysql_fix_privilege_tables
 
@@ -1548,7 +1550,7 @@ echo "====="                                     >> $STATUS_HISTORY
 
 * Thu Nov 30 2006 Joerg Bruehe <joerg@mysql.com>
 
-- Call "make install" using "benchdir_root=%{_datadir}",
+- Call "make install" using "benchdir_root=%%{_datadir}",
   because that is affecting the regression test suite as well.
 
 * Thu Nov 16 2006 Joerg Bruehe <joerg@mysql.com>
@@ -1627,7 +1629,7 @@ echo "====="                                     >> $STATUS_HISTORY
 
 - Set $LDFLAGS from $MYSQL_BUILD_LDFLAGS
 
-* Wed Mar 07 2006 Kent Boortz <kent@mysql.com>
+* Tue Mar 07 2006 Kent Boortz <kent@mysql.com>
 
 - Changed product name from "Community Edition" to "Community Server"
 
@@ -1665,7 +1667,7 @@ echo "====="                                     >> $STATUS_HISTORY
 - Added zlib to the list of (static) libraries installed
 - Added check against libtool wierdness (WRT: sql/mysqld || sql/.libs/mysqld)
 - Compile MySQL with bundled zlib
-- Fixed %packager name to "MySQL Production Engineering Team"
+- Fixed %%packager name to "MySQL Production Engineering Team"
 
 * Mon Dec 05 2005 Joerg Bruehe <joerg@mysql.com>
 
@@ -1815,7 +1817,7 @@ echo "====="                                     >> $STATUS_HISTORY
 - ISAM and merge storage engines were purged. As well as appropriate
   tools and manpages (isamchk and isamlog)
 
-* Thu Dec 31 2004 Lenz Grimmer <lenz@mysql.com>
+* Fri Dec 31 2004 Lenz Grimmer <lenz@mysql.com>
 
 - enabled the "Archive" storage engine for the max binary
 - enabled the "CSV" storage engine for the max binary
@@ -1875,7 +1877,7 @@ echo "====="                                     >> $STATUS_HISTORY
 
 - marked /etc/logrotate.d/mysql as a config file (BUG 2156)
 
-* Fri Dec 13 2003 Lenz Grimmer <lenz@mysql.com>
+* Sat Dec 13 2003 Lenz Grimmer <lenz@mysql.com>
 
 - fixed file permissions (BUG 1672)
 
@@ -2017,7 +2019,7 @@ echo "====="                                     >> $STATUS_HISTORY
 - Added separate libmysql_r directory; now both a threaded
   and non-threaded library is shipped.
 
-* Wed Sep 28 1999 David Axmark <davida@mysql.com>
+* Tue Sep 28 1999 David Axmark <davida@mysql.com>
 
 - Added the support-files/my-example.cnf to the docs directory.
 
diff --git a/tests/fork_big.pl b/tests/fork_big.pl
index b866b899f8d3f98ccbdb700080e5187d2293d1c7..6e78e779d11189cdf714cbf831531e1ca7a4b611 100755
--- a/tests/fork_big.pl
+++ b/tests/fork_big.pl
@@ -2,7 +2,7 @@
 
 # Copyright (c) 2001, 2006 MySQL AB
 #   Use is subject to license terms
- 
+# 
 # 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
 # the Free Software Foundation; version 2 of the License.
diff --git a/tests/fork_big2.pl b/tests/fork_big2.pl
index e92cf869e526b320920f5331329d95dc3adfa567..0f1d65be8f9366dc5830b6e0f6fe30604bf70ba6 100644
--- a/tests/fork_big2.pl
+++ b/tests/fork_big2.pl
@@ -2,7 +2,7 @@
 
 # Copyright (c) 2002, 2003, 2005, 2006 MySQL AB
 #   Use is subject to license terms
- 
+# 
 # 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
 # the Free Software Foundation; version 2 of the License.