From aa8b8e3ab1ec2cdaca3c51f651f7f8d8a928bbdf Mon Sep 17 00:00:00 2001 From: Bjorn Munch Date: Mon, 31 Oct 2016 15:01:19 +0100 Subject: [PATCH 01/54] Raise version number after cloning 5.5.54 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 4f1ecb3a1972b..bc0b19220b64e 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=5 MYSQL_VERSION_MINOR=5 -MYSQL_VERSION_PATCH=54 +MYSQL_VERSION_PATCH=55 MYSQL_VERSION_EXTRA= From b8ec8196c3df6c1de6fdc547a2b208093babfb01 Mon Sep 17 00:00:00 2001 From: Shipra Jain Date: Sat, 5 Nov 2016 16:52:05 +0100 Subject: [PATCH 02/54] Bug#24918325: backport bug11756699 in this patch --- mysql-test/r/log_tables-big.result | 2 ++ mysql-test/t/disabled.def | 1 - mysql-test/t/log_tables-big.test | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/log_tables-big.result b/mysql-test/r/log_tables-big.result index 9b81127c82562..42df9e8fe1675 100644 --- a/mysql-test/r/log_tables-big.result +++ b/mysql-test/r/log_tables-big.result @@ -1,3 +1,4 @@ +set @@global.log_output = 'TABLE'; set session long_query_time=10; select get_lock('bug27638', 1); get_lock('bug27638', 1) @@ -27,3 +28,4 @@ OK select get_lock('bug27638', 101) select release_lock('bug27638'); release_lock('bug27638') 1 +set @@global.log_output=default; diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 81600642c15e7..ef973912b6370 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -13,5 +13,4 @@ lowercase_table3 : Bug#11762269 2010-06-30 alik main.lowercase_table3 on read_many_rows_innodb : Bug#11748886 2010-11-15 mattiasj report already exists sum_distinct-big : Bug#11764126 2010-11-15 mattiasj was not tested archive-big : Bug#11817185 2011-03-10 Anitha Disabled since this leads to timeout on Solaris Sparc -log_tables-big : Bug#11756699 2010-11-15 mattiasj report already exists mysql_embedded : Bug#12561297 2011-05-14 Anitha Dependent on PB2 changes - eventum#41836 diff --git a/mysql-test/t/log_tables-big.test b/mysql-test/t/log_tables-big.test index 8c956fa6f5512..4a10ea12edf05 100644 --- a/mysql-test/t/log_tables-big.test +++ b/mysql-test/t/log_tables-big.test @@ -7,6 +7,8 @@ # check that CSV engine was compiled in --source include/have_csv.inc +set @@global.log_output = 'TABLE'; + connect (con1,localhost,root,,); connect (con2,localhost,root,,); @@ -33,3 +35,5 @@ connection default; disconnect con1; disconnect con2; + +set @@global.log_output=default; From 2f2103d540f86e326b22cef39183e8e0985da138 Mon Sep 17 00:00:00 2001 From: Shipra Jain Date: Wed, 9 Nov 2016 19:27:35 +0100 Subject: [PATCH 03/54] Bug#22874167 : fix for MAIN.LOG_TABLES-BIG UNSTABLE ON LOADED HOSTS --- mysql-test/r/log_tables-big.result | 12 ++++++------ mysql-test/t/log_tables-big.test | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/log_tables-big.result b/mysql-test/r/log_tables-big.result index 42df9e8fe1675..1e189a7726fbf 100644 --- a/mysql-test/r/log_tables-big.result +++ b/mysql-test/r/log_tables-big.result @@ -4,25 +4,25 @@ select get_lock('bug27638', 1); get_lock('bug27638', 1) 1 set session long_query_time=1; -truncate table mysql.slow_log; select get_lock('bug27638', 2); get_lock('bug27638', 2) 0 -select if (query_time between '00:00:01' and '00:00:10', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log; +select if (query_time >= '00:00:01', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log +where sql_text = 'select get_lock(\'bug27638\', 2)'; qt sql_text OK select get_lock('bug27638', 2) -truncate table mysql.slow_log; select get_lock('bug27638', 60); get_lock('bug27638', 60) 0 -select if (query_time between '00:00:59' and '00:01:10', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log; +select if (query_time >= '00:00:59', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log +where sql_text = 'select get_lock(\'bug27638\', 60)'; qt sql_text OK select get_lock('bug27638', 60) -truncate table mysql.slow_log; select get_lock('bug27638', 101); get_lock('bug27638', 101) 0 -select if (query_time between '00:01:40' and '00:01:50', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log; +select if (query_time >= '00:01:40', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log +where sql_text = 'select get_lock(\'bug27638\', 101)'; qt sql_text OK select get_lock('bug27638', 101) select release_lock('bug27638'); diff --git a/mysql-test/t/log_tables-big.test b/mysql-test/t/log_tables-big.test index 4a10ea12edf05..8936a163d738c 100644 --- a/mysql-test/t/log_tables-big.test +++ b/mysql-test/t/log_tables-big.test @@ -20,15 +20,15 @@ set session long_query_time=10; select get_lock('bug27638', 1); connection con2; set session long_query_time=1; -truncate table mysql.slow_log; select get_lock('bug27638', 2); -select if (query_time between '00:00:01' and '00:00:10', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log; -truncate table mysql.slow_log; +select if (query_time >= '00:00:01', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log + where sql_text = 'select get_lock(\'bug27638\', 2)'; select get_lock('bug27638', 60); -select if (query_time between '00:00:59' and '00:01:10', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log; -truncate table mysql.slow_log; +select if (query_time >= '00:00:59', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log + where sql_text = 'select get_lock(\'bug27638\', 60)'; select get_lock('bug27638', 101); -select if (query_time between '00:01:40' and '00:01:50', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log; +select if (query_time >= '00:01:40', 'OK', 'WRONG') as qt, sql_text from mysql.slow_log + where sql_text = 'select get_lock(\'bug27638\', 101)'; connection con1; select release_lock('bug27638'); connection default; From a63185e8638365d401732803ba93b6b149d33c65 Mon Sep 17 00:00:00 2001 From: Karthik Kamath Date: Thu, 10 Nov 2016 15:11:57 +0530 Subject: [PATCH 04/54] BUG#24437124: POSSIBLE BUFFER OVERFLOW ON CREATE TABLE ANALYSIS: ========= 'CREATE TABLE' query with a large value for 'CONNECTION' string reports an incorrect error. The length of connection string is stored in .frm in two bytes (max value= 65535). When the string length exceeds the max value, the length is truncated to fit the two bytes limit. Further processing leads to reading only a part of the string as the length stored is incorrect. The remaining part of the string is treated as engine type and hence results in an error. FIX: ==== We are now restricting the connection string length to 1024. An appropriate error is reported if the length crosses this limit. NOTE: ===== The 'PASSWORD' table option is documented as unused and processed within a dead code. Hence it will not cause similar issue with large strings. --- include/mysql_com.h | 3 ++- sql/sql_table.cc | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/mysql_com.h b/include/mysql_com.h index f2345be6fd6eb..5cd4091574349 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2016, 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 @@ -26,6 +26,7 @@ #define USERNAME_CHAR_LENGTH 16 #define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN) #define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN) +#define CONNECT_STRING_MAXLEN 1024 #define MYSQL_AUTODETECT_CHARSET_NAME "auto" diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 49f05c6116e18..58bcf5ca1d4c1 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2851,6 +2851,21 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, uint total_uneven_bit_length= 0; DBUG_ENTER("mysql_prepare_create_table"); + LEX_STRING* connect_string = &create_info->connect_string; + if (connect_string->length != 0 && + connect_string->length > CONNECT_STRING_MAXLEN && + (system_charset_info->cset->charpos(system_charset_info, + connect_string->str, + (connect_string->str + + connect_string->length), + CONNECT_STRING_MAXLEN) + < connect_string->length)) + { + my_error(ER_WRONG_STRING_LENGTH, MYF(0), + connect_string->str, "CONNECTION", CONNECT_STRING_MAXLEN); + DBUG_RETURN(TRUE); + } + select_field_pos= alter_info->create_list.elements - select_field_count; null_fields=blob_columns=0; create_info->varchar= 0; From cdd57aa719c14f4c2e23ad37674db5b8ca18fe9e Mon Sep 17 00:00:00 2001 From: Terje Rosten Date: Wed, 16 Nov 2016 13:41:27 +0100 Subject: [PATCH 05/54] Bug#25088048 ADDITIONAL ISSUES IN MYSQLD_SAFE Don't read --ledir option from config file. Ignore current working for finding location of mysqld Remove use of chown/chmod in scripts. Be helpful only when basedir is /var/log or /var/lib. Removed unused systemd files for SLES. Set explicit basedir in scripts. --- packaging/rpm-oel/mysql-systemd-start | 4 +- packaging/rpm-oel/mysql.init | 24 +++++----- packaging/rpm-oel/mysqld.service | 2 +- packaging/rpm-sles/CMakeLists.txt | 3 +- packaging/rpm-sles/mysql-systemd-start | 66 -------------------------- packaging/rpm-sles/mysql.conf | 1 - packaging/rpm-sles/mysql.init | 13 ++--- packaging/rpm-sles/mysqld.service | 48 ------------------- scripts/mysqld_safe.sh | 18 ++++++- 9 files changed, 41 insertions(+), 138 deletions(-) delete mode 100644 packaging/rpm-sles/mysql-systemd-start delete mode 100644 packaging/rpm-sles/mysql.conf delete mode 100644 packaging/rpm-sles/mysqld.service diff --git a/packaging/rpm-oel/mysql-systemd-start b/packaging/rpm-oel/mysql-systemd-start index 231a76087ac3e..af6e906efe135 100644 --- a/packaging/rpm-oel/mysql-systemd-start +++ b/packaging/rpm-oel/mysql-systemd-start @@ -22,7 +22,9 @@ install_db () { 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 + if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + install -d -m 0755 -omysql -gmysql "$datadir" || exit 1 + fi log=/var/log/mysqld.log [ -e $log ] || touch $log chmod 0640 $log diff --git a/packaging/rpm-oel/mysql.init b/packaging/rpm-oel/mysql.init index 75ae672801b77..50d1bba017dea 100644 --- a/packaging/rpm-oel/mysql.init +++ b/packaging/rpm-oel/mysql.init @@ -70,18 +70,19 @@ start(){ ret=0 else # prepare for start - touch "$errlogfile" - chown mysql:mysql "$errlogfile" - chmod 0640 "$errlogfile" + if [ ! -e "$errlogfile" -a ! -h "$errlogfile" -a "x$(dirname "$errlogfile")" = "x/var/log" ]; then + install /dev/null -m0640 -omysql -gmysql "$errlogfile" + fi [ -x /sbin/restorecon ] && /sbin/restorecon "$errlogfile" if [ ! -d "$datadir/mysql" ] ; then # First, make sure $datadir is there with correct permissions - if [ ! -e "$datadir" -a ! -h "$datadir" ] - then - mkdir -p "$datadir" || exit 1 + if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + install -d -m0755 -omysql -gmysql "$datadir" || exit 1 + fi + if [ ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + chown mysql:mysql "$datadir" + chmod 0755 "$datadir" fi - chown mysql:mysql "$datadir" - chmod 0755 "$datadir" if [ -x /sbin/restorecon ]; then /sbin/restorecon "$datadir" for dir in /var/lib/mysql-files ; do @@ -94,13 +95,14 @@ start(){ # Now create the database action $"Initializing MySQL database: " /usr/bin/mysql_install_db --rpm --datadir="$datadir" --user=mysql ret=$? - chown -R mysql:mysql "$datadir" if [ $ret -ne 0 ] ; then return $ret fi fi - chown mysql:mysql "$datadir" - chmod 0755 "$datadir" + if [ ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + chown mysql:mysql "$datadir" + chmod 0755 "$datadir" + fi # Pass all the options determined above, to ensure consistent behavior. # In many cases mysqld_safe would arrive at the same conclusions anyway # but we need to be sure. (An exception is that we don't force the diff --git a/packaging/rpm-oel/mysqld.service b/packaging/rpm-oel/mysqld.service index 78ef3bffe601c..871f191c0171a 100644 --- a/packaging/rpm-oel/mysqld.service +++ b/packaging/rpm-oel/mysqld.service @@ -34,7 +34,7 @@ PermissionsStartOnly=true ExecStartPre=/usr/bin/mysql-systemd-start pre # Start main service -ExecStart=/usr/bin/mysqld_safe +ExecStart=/usr/bin/mysqld_safe --basedir=/usr # Don't signal startup success before a ping works ExecStartPost=/usr/bin/mysql-systemd-start post diff --git a/packaging/rpm-sles/CMakeLists.txt b/packaging/rpm-sles/CMakeLists.txt index b5ffaa1556574..98aa4f4d222b4 100644 --- a/packaging/rpm-sles/CMakeLists.txt +++ b/packaging/rpm-sles/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2012, 2016, 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 @@ -20,7 +20,6 @@ IF(UNIX) # Left in current directory, to be taken during build CONFIGURE_FILE(mysql.spec.in ${CMAKE_CURRENT_BINARY_DIR}/${SPECFILENAME} @ONLY) FOREACH(fedfile my.cnf my_config.h mysql.init - mysqld.service mysql-systemd-start mysql.conf filter-requires.sh filter-provides.sh) CONFIGURE_FILE(${fedfile} ${CMAKE_CURRENT_BINARY_DIR}/${fedfile} COPYONLY) ENDFOREACH() diff --git a/packaging/rpm-sles/mysql-systemd-start b/packaging/rpm-sles/mysql-systemd-start deleted file mode 100644 index 28472249eda16..0000000000000 --- a/packaging/rpm-sles/mysql-systemd-start +++ /dev/null @@ -1,66 +0,0 @@ -#! /bin/bash -# -# Scripts to run by MySQL systemd service -# -# Needed argument: pre | post -# -# pre mode : try to run mysql_install_db and fix perms and SELinux contexts -# post mode : ping server until answer is received -# - -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' | tail -n 1) - - # Restore log, dir, perms and SELinux contexts - [ -d "$datadir" ] || install -d -m 0755 -omysql -gmysql "$datadir" || exit 1 - log=/var/log/mysqld.log - [ -e $log ] || touch $log - chmod 0640 $log - chown mysql:mysql $log || exit 1 - if [ -x /usr/sbin/restorecon ]; then - /usr/sbin/restorecon "$datadir" - /usr/sbin/restorecon $log - fi - - # If special mysql dir is in place, skip db install - [ -d "$datadir/mysql" ] && exit 0 - - # Create initial db - /usr/bin/mysql_install_db --rpm --datadir="$datadir" --user=mysql - - # Create a file to trigger execution of mysql_secure_installation - # after server has started - touch "$datadir"/.phase_two_required - - exit 0 -} - -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 - ret=1 - while /bin/true ; do - sleep 1 - mysqladmin ping >/dev/null 2>&1 && ret=0 && break - done - - # If server has been started successfully and file created in - # install_db step is present we run mysql_secure_installation - if [ $ret -eq 0 -a -e "$datadir"/.phase_two_required -a -x /usr/bin/mysql_secure_installation ] ; then - /usr/bin/mysql_secure_installation --use-default --defaults-file=/etc/my.cnf - rm -f "$datadir"/.phase_two_required - fi - - exit 0 -} - -# main -case $1 in - "pre") install_db ;; - "post") pinger ;; -esac - -exit 0 - diff --git a/packaging/rpm-sles/mysql.conf b/packaging/rpm-sles/mysql.conf deleted file mode 100644 index 74cd5f836e76f..0000000000000 --- a/packaging/rpm-sles/mysql.conf +++ /dev/null @@ -1 +0,0 @@ -d /var/run/mysqld 0755 mysql mysql - diff --git a/packaging/rpm-sles/mysql.init b/packaging/rpm-sles/mysql.init index dda0bebba5658..25762d9bee263 100644 --- a/packaging/rpm-sles/mysql.init +++ b/packaging/rpm-sles/mysql.init @@ -49,7 +49,6 @@ get_option () { datadir=$(get_option mysqld datadir "/var/lib/mysql") socket=$(get_option mysqld socket "$datadir/mysql.sock") pidfile=$(get_option mysqld_safe pid-file "/var/run/mysql/mysqld.pid") -logfile=$(get_option mysqld_safe log-error "/var/log/mysql/mysqld.log") install_db () { # Note: something different than datadir=/var/lib/mysql requires @@ -58,14 +57,16 @@ install_db () { logfile=$(get_option mysqld_safe log-error "/var/log/mysql/mysqld.log") # Restore log, dir, perms and SELinux contexts - [ -d "$datadir" ] || install -d -m 0755 -omysql -gmysql "$datadir" || return 1 + if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + install -d -m 0755 -omysql -gmysql "$datadir" || return 1 + fi - [ -e $logfile ] || touch $logfile || return 1 - chmod 0640 $logfile - chown mysql:mysql $logfile || return 1 + if [ ! -e "$logfile" -a ! -h "$logfile" -a "x$(dirname "$logfile")" = "x/var/log/mysql" ]; then + install /dev/null -omysql -gmysql "$logfile" || return 1 + fi if [ -x /usr/sbin/restorecon ]; then /usr/sbin/restorecon "$datadir" - /usr/sbin/restorecon $logfile + /usr/sbin/restorecon "$logfile" fi # If special mysql dir is in place, skip db install diff --git a/packaging/rpm-sles/mysqld.service b/packaging/rpm-sles/mysqld.service deleted file mode 100644 index 78ef3bffe601c..0000000000000 --- a/packaging/rpm-sles/mysqld.service +++ /dev/null @@ -1,48 +0,0 @@ -# -# Simple MySQL systemd service file -# -# systemd supports lots of fancy features, look here (and linked docs) for a full list: -# http://www.freedesktop.org/software/systemd/man/systemd.exec.html -# -# Note: this file ( /usr/lib/systemd/system/mysql.service ) -# will be overwritten on package upgrade, please copy the file to -# -# /etc/systemd/system/mysql.service -# -# to make needed changes. -# -# systemd-delta can be used to check differences between the two mysql.service files. -# - -[Unit] -Description=MySQL Community Server -After=network.target -After=syslog.target - -[Install] -WantedBy=multi-user.target -Alias=mysql.service - -[Service] -User=mysql -Group=mysql - -# Execute pre and post scripts as root -PermissionsStartOnly=true - -# Needed to create system tables etc. -ExecStartPre=/usr/bin/mysql-systemd-start pre - -# Start main service -ExecStart=/usr/bin/mysqld_safe - -# Don't signal startup success before a ping works -ExecStartPost=/usr/bin/mysql-systemd-start post - -# Give up if ping don't get an answer -TimeoutSec=600 - -Restart=always -PrivateTmp=false - - diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 4b103817ab67d..a5c87a44e65c8 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -218,7 +218,13 @@ parse_arguments() { # mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])! --core-file-size=*) core_file_size="$val" ;; - --ledir=*) ledir="$val" ;; + --ledir=*) + if [ -z "$pick_args" ]; then + log_error "--ledir option can only be used as command line option, found in config file" + exit 1 + fi + ledir="$val" + ;; --malloc-lib=*) set_malloc_lib "$val" ;; --mysqld=*) if [ -z "$pick_args" ]; then @@ -394,7 +400,15 @@ else relpkgdata='@pkgdatadir@' fi -MY_PWD=`pwd` +case "$0" in + /*) + MY_PWD='@prefix@' + ;; + *) + MY_PWD=`dirname $0` + MY_PWD=`dirname $MY_PWD` + ;; +esac # Check for the directories we would expect from a binary release install if test -n "$MY_BASEDIR_VERSION" -a -d "$MY_BASEDIR_VERSION" then From e541c414816e904124ba7ab3075c3851da0addda Mon Sep 17 00:00:00 2001 From: Dyre Tjeldvoll Date: Thu, 24 Nov 2016 09:57:54 +0100 Subject: [PATCH 06/54] Bug#25092566: CREATE TABLE WITH DATA DIRECTORY CLAUSE DOES NOT REQUIRE SPECIAL PRIVILEGES Require FILE privilege when creating tables using external data directory or index directory. --- mysql-test/r/partition_symlink.result | 2 ++ mysql-test/t/partition_symlink.test | 2 ++ sql/partition_info.cc | 26 +++++++++++++++++++++++++- sql/partition_info.h | 13 ++++++++++++- sql/sql_parse.cc | 19 ++++++++++++++++++- 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/partition_symlink.result b/mysql-test/r/partition_symlink.result index f26a1642a529e..91cc78f136127 100644 --- a/mysql-test/r/partition_symlink.result +++ b/mysql-test/r/partition_symlink.result @@ -4,6 +4,8 @@ DROP DATABASE IF EXISTS mysqltest2; # test.t1 have partitions in mysqltest2-directory! # user root: CREATE USER mysqltest_1@localhost; +# Need FILE permission to use external datadir or indexdir. +GRANT FILE ON *.* TO mysqltest_1@localhost; CREATE DATABASE mysqltest2; USE mysqltest2; CREATE TABLE t1 (a INT) ENGINE = MyISAM; diff --git a/mysql-test/t/partition_symlink.test b/mysql-test/t/partition_symlink.test index 5fdde8e0abc28..9e57d6162130f 100644 --- a/mysql-test/t/partition_symlink.test +++ b/mysql-test/t/partition_symlink.test @@ -32,6 +32,8 @@ DROP DATABASE IF EXISTS mysqltest2; -- echo # test.t1 have partitions in mysqltest2-directory! -- echo # user root: CREATE USER mysqltest_1@localhost; +-- echo # Need FILE permission to use external datadir or indexdir. + GRANT FILE ON *.* TO mysqltest_1@localhost; CREATE DATABASE mysqltest2; USE mysqltest2; CREATE TABLE t1 (a INT) ENGINE = MyISAM; diff --git a/sql/partition_info.cc b/sql/partition_info.cc index a0d09557b81cb..cd17e3366cfb7 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2006, 2016, 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 @@ -2550,6 +2550,30 @@ void partition_info::print_debug(const char *str, uint *value) DBUG_PRINT("info", ("parser: %s", str)); DBUG_VOID_RETURN; } + +bool has_external_data_or_index_dir(partition_info &pi) +{ + List_iterator part_it(pi.partitions); + for (partition_element *part= part_it++; part; part= part_it++) + { + if (part->data_file_name != NULL || part->index_file_name != NULL) + { + return true; + } + List_iterator subpart_it(part->subpartitions); + for (const partition_element *subpart= subpart_it++; + subpart; + subpart= subpart_it++) + { + if (subpart->data_file_name != NULL || subpart->index_file_name != NULL) + { + return true; + } + } + } + return false; +} + #else /* WITH_PARTITION_STORAGE_ENGINE */ /* For builds without partitioning we need to define these functions diff --git a/sql/partition_info.h b/sql/partition_info.h index 7bfbf8a1b1a1b..7ff6abeebd24c 100644 --- a/sql/partition_info.h +++ b/sql/partition_info.h @@ -1,7 +1,7 @@ #ifndef PARTITION_INFO_INCLUDED #define PARTITION_INFO_INCLUDED -/* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2006, 2016, 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 @@ -349,4 +349,15 @@ void init_all_partitions_iterator(partition_info *part_info, part_iter->get_next= get_next_partition_id_range; } +/** + Predicate which returns true if any partition or subpartition uses + an external data directory or external index directory. + + @param pi partitioning information + @retval true if any partition or subpartition has an external + data directory or external index directory. + @retval false otherwise + */ +bool has_external_data_or_index_dir(partition_info &pi); + #endif /* PARTITION_INFO_INCLUDED */ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ac3901997f314..18cb758c9b559 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -35,6 +35,9 @@ #include "sql_insert.h" // mysql_insert #include "sql_update.h" // mysql_update, mysql_multi_update #include "sql_partition.h" // struct partition_info +#ifdef WITH_PARTITION_STORAGE_ENGINE +#include "partition_info.h" // has_external_data_or_index_dir +#endif /* WITH_PARTITION_STORAGE_ENGINE */ #include "sql_db.h" // mysql_change_db, mysql_create_db, // mysql_rm_db, mysql_upgrade_db, // mysql_alter_db, @@ -2413,7 +2416,6 @@ case SQLCOM_PREPARE: copy. */ Alter_info alter_info(lex->alter_info, thd->mem_root); - if (thd->is_fatal_error) { /* If out of memory when creating a copy of alter_info. */ @@ -2421,6 +2423,15 @@ case SQLCOM_PREPARE: goto end_with_restore_list; } + if (((lex->create_info.used_fields & HA_CREATE_USED_DATADIR) != 0 || + (lex->create_info.used_fields & HA_CREATE_USED_INDEXDIR) != 0) && + check_access(thd, FILE_ACL, NULL, NULL, NULL, FALSE, FALSE)) + { + res= 1; + my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "FILE"); + goto end_with_restore_list; + } + if ((res= create_table_precheck(thd, select_tables, create_table))) goto end_with_restore_list; @@ -2458,6 +2469,12 @@ case SQLCOM_PREPARE: #ifdef WITH_PARTITION_STORAGE_ENGINE { partition_info *part_info= thd->lex->part_info; + if (part_info != NULL && has_external_data_or_index_dir(*part_info) && + check_access(thd, FILE_ACL, NULL, NULL, NULL, FALSE, FALSE)) + { + res= -1; + goto end_with_restore_list; + } if (part_info && !(part_info= thd->lex->part_info->get_clone(true))) { res= -1; From 04cdb9905ab84c1a0cb3583f94d778f59a1b7d73 Mon Sep 17 00:00:00 2001 From: "mysql-builder@oracle.com" <> Date: Thu, 24 Nov 2016 21:53:55 +0100 Subject: [PATCH 07/54] From 07fb5cffb035c622927c59188f0f062595eb2847 Mon Sep 17 00:00:00 2001 From: Balasubramanian Kandasamy Date: Sat, 26 Nov 2016 20:41:48 +0530 Subject: [PATCH 08/54] Followup fix for Bug#25088048 - ADDITIONAL ISSUES IN MYSQLD_SAFE - Removed mysql.conf, mysqld.service and mysql-systemd-start from sles spec file --- packaging/rpm-sles/mysql.spec.in | 43 -------------------------------- 1 file changed, 43 deletions(-) diff --git a/packaging/rpm-sles/mysql.spec.in b/packaging/rpm-sles/mysql.spec.in index 6652cdcccb614..1b5f1806321e0 100644 --- a/packaging/rpm-sles/mysql.spec.in +++ b/packaging/rpm-sles/mysql.spec.in @@ -24,7 +24,6 @@ # Regression tests may take a long time, override the default to skip them %{!?runselftest:%global runselftest 0} -%{!?with_systemd: %global systemd 0} %{!?with_debuginfo: %global nodebuginfo 1} %{!?product_suffix: %global product_suffix community} %{!?feature_set: %global feature_set community} @@ -69,9 +68,6 @@ Source0: https://cdn.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/%{src URL: http://www.mysql.com/ Packager: MySQL Release Engineering Vendor: %{mysql_vendor} -Source1: mysql-systemd-start -Source2: mysqld.service -Source3: mysql.conf Source4: my_config.h Source90: filter-provides.sh Source91: filter-requires.sh @@ -81,9 +77,6 @@ BuildRequires: libaio-devel BuildRequires: ncurses-devel BuildRequires: openssl-devel BuildRequires: zlib-devel -%if 0%{?systemd} -BuildRequires: systemd -%endif BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) %if 0%{?rhel} > 6 @@ -141,15 +134,9 @@ Obsoletes: mariadb-server Obsoletes: mariadb-galera-server Provides: mysql = %{version}-%{release} Provides: mysql-tools = %{version}-%{release} -%if 0%{?systemd} -Requires(post): systemd -Requires(preun): systemd -Requires(postun): systemd -%else PreReq: insserv PreReq: sed PreReq: pwdutils -%endif Conflicts: otherproviders(mysql) Conflicts: otherproviders(mysql-debug) Conflicts: otherproviders(mysql-tools) @@ -435,13 +422,7 @@ make DESTDIR=%{buildroot} install install -D -m 0644 $MBD/release/support-files/mysql-log-rotate %{buildroot}%{_sysconfdir}/logrotate.d/mysql install -D -m 0644 $MBD/release/packaging/rpm-sles/my.cnf %{buildroot}%{_sysconfdir}/my.cnf install -d %{buildroot}%{_sysconfdir}/my.cnf.d -%if 0%{?systemd} -install -D -m 0755 %{SOURCE1} %{buildroot}%{_bindir}/mysql-systemd-start -install -D -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/mysqld.service -%else install -D -m 0755 $MBD/release/packaging/rpm-sles/mysql.init %{buildroot}%{_sysconfdir}/init.d/mysql -%endif -install -D -m 0644 %{SOURCE3} %{buildroot}%{_prefix}/lib/tmpfiles.d/mysql.conf # Make library links install -d -m 0755 %{buildroot}%{_sysconfdir}/ld.so.conf.d @@ -461,9 +442,6 @@ rm -rf %{buildroot}%{_datadir}/mysql/mysql.server rm -rf %{buildroot}%{_datadir}/mysql/mysqld_multi.server rm -f %{buildroot}%{_datadir}/mysql/{ndb-config-2-node,config*}.ini rm -f %{buildroot}%{_datadir}/mysql/my-*.cnf -%if 0%{?systemd} -rm -rf %{buildroot}%{_sysconfdir}/init.d/mysql -%endif rm -rf %{buildroot}%{_bindir}/mysql_embedded rm -rf %{buildroot}%{_bindir}/mysql_setpermission rm -rf %{buildroot}%{_mandir}/man1/mysql_setpermission.1* @@ -496,31 +474,18 @@ datadir=$(/usr/bin/my_print_defaults server mysqld | grep '^--datadir=' | sed -n /bin/chmod 0755 "$datadir" /bin/touch /var/log/mysql/mysqld.log /bin/chown mysql:mysql /var/log/mysql/mysqld.log >/dev/null 2>&1 || : -%if 0%{?systemd} -%systemd_post mysqld.service -/sbin/service mysqld enable >/dev/null 2>&1 || : -%else /sbin/insserv /etc/init.d/mysql -%endif %preun server -%if 0%{?systemd} -%systemd_preun mysqld.service -%else if [ "$1" -eq 0 ]; then /usr/sbin/rcmysql stop >/dev/null 2>&1 || : /sbin/insserv /etc/init.d fi -%endif %postun server -%if 0%{?systemd} -%systemd_postun_with_restart mysqld.service -%else if [ $1 -ge 1 ]; then /usr/sbin/rcmysql condrestart >/dev/null 2>&1 || : fi -%endif %post libs -p /sbin/ldconfig @@ -596,9 +561,6 @@ fi %attr(755, root, root) %{_bindir}/replace %attr(755, root, root) %{_bindir}/resolve_stack_dump %attr(755, root, root) %{_bindir}/resolveip -%if 0%{?systemd} -%attr(755, root, root) %{_bindir}/mysql-systemd-start -%endif %attr(755, root, root) %{_sbindir}/mysqld %attr(755, root, root) %{_sbindir}/mysqld-debug %attr(755, root, root) %{_sbindir}/rcmysql @@ -629,12 +591,7 @@ fi %attr(644, root, root) %{_datadir}/mysql/mysql_test_data_timezone.sql %attr(644, root, root) %{_datadir}/mysql/mysql-log-rotate %attr(644, root, root) %{_datadir}/mysql/magic -%attr(644, root, root) %{_prefix}/lib/tmpfiles.d/mysql.conf -%if 0%{?systemd} -%attr(644, root, root) %{_unitdir}/mysqld.service -%else %attr(755, root, root) %{_sysconfdir}/init.d/mysql -%endif %attr(644, root, root) %config(noreplace,missingok) %{_sysconfdir}/logrotate.d/mysql %dir %attr(755, mysql, mysql) /var/lib/mysql %dir %attr(755, mysql, mysql) /var/run/mysql From 3a37745ca048e7b1faf726a15929ae944d7e25ed Mon Sep 17 00:00:00 2001 From: Arun Kuruvila Date: Mon, 28 Nov 2016 11:55:36 +0530 Subject: [PATCH 09/54] --- sql/sp.cc | 4 +- sql/sql_acl.cc | 501 ++++++++++++++++++++++++++++++++++++++++++++++++- sql/sql_acl.h | 99 +++++++++- sql/table.cc | 40 ++-- 4 files changed, 618 insertions(+), 26 deletions(-) diff --git a/sql/sp.cc b/sql/sp.cc index a514ca10a68ae..56a439481f5c5 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2002, 2016, 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 @@ -372,7 +372,7 @@ void Proc_table_intact::report_error(uint code, const char *fmt, ...) my_vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); - if (code) + if (code == ER_COL_COUNT_DOESNT_MATCH_CORRUPTED) my_message(code, buf, MYF(0)); else my_error(ER_CANNOT_LOAD_FROM_TABLE, MYF(0), "proc"); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 99394878a55d2..b48b856267902 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -168,9 +168,411 @@ TABLE_FIELD_TYPE mysql_db_table_fields[MYSQL_DB_FIELD_COUNT] = { } }; +static const +TABLE_FIELD_TYPE mysql_user_table_fields[MYSQL_USER_FIELD_COUNT] = { + { + { C_STRING_WITH_LEN("Host") }, + { C_STRING_WITH_LEN("char(60)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("User") }, + { C_STRING_WITH_LEN("char(16)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Password") }, + { C_STRING_WITH_LEN("char(41)") }, + { C_STRING_WITH_LEN("latin1") } + }, + { + { C_STRING_WITH_LEN("Select_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Insert_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Update_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Delete_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Create_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Drop_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Reload_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Shutdown_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Process_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("File_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Grant_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("References_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Index_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Alter_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Show_db_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Super_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Create_tmp_table_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Lock_tables_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Execute_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Repl_slave_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Repl_client_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Create_view_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Show_view_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Create_routine_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Alter_routine_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Create_user_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Event_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Trigger_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Create_tablespace_priv") }, + { C_STRING_WITH_LEN("enum('N','Y')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("ssl_type") }, + { C_STRING_WITH_LEN("enum('','ANY','X509','SPECIFIED')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("ssl_cipher") }, + { C_STRING_WITH_LEN("blob") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("x509_issuer") }, + { C_STRING_WITH_LEN("blob") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("x509_subject") }, + { C_STRING_WITH_LEN("blob") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("max_questions") }, + { C_STRING_WITH_LEN("int(11)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("max_updates") }, + { C_STRING_WITH_LEN("int(11)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("max_connections") }, + { C_STRING_WITH_LEN("int(11)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("max_user_connections") }, + { C_STRING_WITH_LEN("int(11)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("plugin") }, + { C_STRING_WITH_LEN("char(64)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("authentication_string") }, + { C_STRING_WITH_LEN("text") }, + {NULL, 0} + } +}; + +static const +TABLE_FIELD_TYPE mysql_proxies_priv_table_fields[MYSQL_PROXIES_PRIV_FIELD_COUNT] = { + { + { C_STRING_WITH_LEN("Host") }, + { C_STRING_WITH_LEN("char(60)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("User") }, + { C_STRING_WITH_LEN("char(16)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Proxied_host") }, + { C_STRING_WITH_LEN("char(60)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Proxied_user") }, + { C_STRING_WITH_LEN("char(16)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("With_grant") }, + { C_STRING_WITH_LEN("tinyint(1)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Grantor") }, + { C_STRING_WITH_LEN("char(77)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Timestamp") }, + { C_STRING_WITH_LEN("timestamp") }, + {NULL, 0} + } +}; + +static const +TABLE_FIELD_TYPE mysql_procs_priv_table_fields[MYSQL_PROCS_PRIV_FIELD_COUNT] = { + { + { C_STRING_WITH_LEN("Host") }, + { C_STRING_WITH_LEN("char(60)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Db") }, + { C_STRING_WITH_LEN("char(64)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("User") }, + { C_STRING_WITH_LEN("char(16)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Routine_name") }, + { C_STRING_WITH_LEN("char(64)") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Routine_type") }, + { C_STRING_WITH_LEN("enum('FUNCTION','PROCEDURE')") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Grantor") }, + { C_STRING_WITH_LEN("char(77)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Proc_priv") }, + { C_STRING_WITH_LEN("set('Execute','Alter Routine','Grant')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Timestamp") }, + { C_STRING_WITH_LEN("timestamp") }, + {NULL, 0} + } +}; + +static const +TABLE_FIELD_TYPE mysql_columns_priv_table_fields[MYSQL_COLUMNS_PRIV_FIELD_COUNT] = { + { + { C_STRING_WITH_LEN("Host") }, + { C_STRING_WITH_LEN("char(60)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Db") }, + { C_STRING_WITH_LEN("char(64)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("User") }, + { C_STRING_WITH_LEN("char(16)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Table_name") }, + { C_STRING_WITH_LEN("char(64)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Column_name") }, + { C_STRING_WITH_LEN("char(64)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Timestamp") }, + { C_STRING_WITH_LEN("timestamp") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Column_priv") }, + { C_STRING_WITH_LEN("set('Select','Insert','Update','References')") }, + { C_STRING_WITH_LEN("utf8") } + } +}; + +static const +TABLE_FIELD_TYPE mysql_tables_priv_table_fields[MYSQL_TABLES_PRIV_FIELD_COUNT] = { + { + { C_STRING_WITH_LEN("Host") }, + { C_STRING_WITH_LEN("char(60)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Db") }, + { C_STRING_WITH_LEN("char(64)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("User") }, + { C_STRING_WITH_LEN("char(16)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Table_name") }, + { C_STRING_WITH_LEN("char(64)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Grantor") }, + { C_STRING_WITH_LEN("char(77)") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Timestamp") }, + { C_STRING_WITH_LEN("timestamp") }, + {NULL, 0} + }, + { + { C_STRING_WITH_LEN("Table_priv") }, + { C_STRING_WITH_LEN("set('Select','Insert','Update','Delete','Create'," + "'Drop','Grant','References','Index','Alter'," + "'Create View','Show view','Trigger')") }, + { C_STRING_WITH_LEN("utf8") } + }, + { + { C_STRING_WITH_LEN("Column_priv") }, + { C_STRING_WITH_LEN("set('Select','Insert','Update','References')") }, + { C_STRING_WITH_LEN("utf8") } + } +}; + + const TABLE_FIELD_DEF mysql_db_table_def= {MYSQL_DB_FIELD_COUNT, mysql_db_table_fields}; +const TABLE_FIELD_DEF + mysql_user_table_def= {MYSQL_USER_FIELD_COUNT, mysql_user_table_fields}; + +const TABLE_FIELD_DEF + mysql_proxies_priv_table_def= {MYSQL_PROXIES_PRIV_FIELD_COUNT, + mysql_proxies_priv_table_fields}; + +const TABLE_FIELD_DEF + mysql_procs_priv_table_def= {MYSQL_PROCS_PRIV_FIELD_COUNT, + mysql_procs_priv_table_fields}; + +const TABLE_FIELD_DEF + mysql_columns_priv_table_def= {MYSQL_COLUMNS_PRIV_FIELD_COUNT, + mysql_columns_priv_table_fields}; + +const TABLE_FIELD_DEF + mysql_tables_priv_table_def= {MYSQL_TABLES_PRIV_FIELD_COUNT, + mysql_tables_priv_table_fields}; + static LEX_STRING native_password_plugin_name= { C_STRING_WITH_LEN("mysql_native_password") }; @@ -519,6 +921,36 @@ static uchar* acl_entry_get_key(acl_entry *entry, size_t *length, return (uchar*) entry->key; } +/** + Class to validate the flawlessness of ACL table + before performing ACL operations. +*/ +class Acl_table_intact : public Table_check_intact +{ +protected: + void report_error(uint code, const char *fmt, ...) + { + va_list args; + va_start(args, fmt); + error_log_print(ERROR_LEVEL, fmt, args); + va_end(args); + if (code) + { + va_start(args, fmt); + if (code == ER_CANNOT_LOAD_FROM_TABLE) + { + char *table_name; + va_arg(args, char *); + table_name= va_arg(args, char *); + my_error(code, MYF(0), table_name); + } + else + my_printv_error(code, ER(code), MYF(0), args); + va_end(args); + } + } +}; + #define IP_ADDR_STRLEN (3 + 1 + 3 + 1 + 3 + 1 + 3) #define ACL_KEY_LENGTH (IP_ADDR_STRLEN + 1 + NAME_LEN + \ 1 + USERNAME_LENGTH + 1) @@ -548,6 +980,7 @@ static bool update_user_table(THD *thd, TABLE *table, static my_bool acl_load(THD *thd, TABLE_LIST *tables); static my_bool grant_load(THD *thd, TABLE_LIST *tables); static inline void get_grantor(THD *thd, char* grantor); + /* Enumeration of various ACL's and Hashes used in handle_grant_struct() */ @@ -1871,6 +2304,7 @@ bool change_password(THD *thd, const char *host, const char *user, { TABLE_LIST tables; TABLE *table; + Acl_table_intact table_intact; /* Buffer should be extended when password length is extended. */ char buff[512]; ulong query_length; @@ -1907,6 +2341,9 @@ bool change_password(THD *thd, const char *host, const char *user, if (!(table= open_ltable(thd, &tables, TL_WRITE, MYSQL_LOCK_IGNORE_TIMEOUT))) DBUG_RETURN(1); + if (table_intact.check(table, &mysql_user_table_def)) + DBUG_RETURN(1); + /* This statement will be replicated as a statement, even when using row-based replication. The flag will be reset at the end of the @@ -2267,10 +2704,14 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo, char what= (revoke_grant) ? 'N' : 'Y'; uchar user_key[MAX_KEY_LENGTH]; LEX *lex= thd->lex; + Acl_table_intact table_intact; DBUG_ENTER("replace_user_table"); mysql_mutex_assert_owner(&acl_cache->lock); + if (table_intact.check(table, &mysql_user_table_def)) + goto end; + if (combo.password.str && combo.password.str[0]) { if (combo.password.length != SCRAMBLED_PASSWORD_CHAR_LENGTH && @@ -2530,6 +2971,7 @@ static int replace_db_table(TABLE *table, const char *db, int error; char what= (revoke_grant) ? 'N' : 'Y'; uchar user_key[MAX_KEY_LENGTH]; + Acl_table_intact table_intact; DBUG_ENTER("replace_db_table"); if (!initialized) @@ -2538,6 +2980,9 @@ static int replace_db_table(TABLE *table, const char *db, DBUG_RETURN(-1); } + if (table_intact.check(table, &mysql_db_table_def)) + DBUG_RETURN(-1); + /* Check if there is such a user in user table in memory? */ if (!find_acl_user(combo.host.str,combo.user.str, FALSE)) { @@ -2678,6 +3123,7 @@ replace_proxies_priv_table(THD *thd, TABLE *table, const LEX_USER *user, uchar user_key[MAX_KEY_LENGTH]; ACL_PROXY_USER new_grant; char grantor[USER_HOST_BUFF_SIZE]; + Acl_table_intact table_intact; DBUG_ENTER("replace_proxies_priv_table"); @@ -2687,6 +3133,9 @@ replace_proxies_priv_table(THD *thd, TABLE *table, const LEX_USER *user, DBUG_RETURN(-1); } + if (table_intact.check(table, &mysql_proxies_priv_table_def)) + DBUG_RETURN(-1); + /* Check if there is such a user in user table in memory? */ if (!find_acl_user(user->host.str,user->user.str, FALSE)) { @@ -3090,9 +3539,13 @@ static int replace_column_table(GRANT_TABLE *g_t, int result=0; uchar key[MAX_KEY_LENGTH]; uint key_prefix_length; - KEY_PART_INFO *key_part= table->key_info->key_part; + KEY_PART_INFO *key_part; + Acl_table_intact table_intact; DBUG_ENTER("replace_column_table"); + if (table_intact.check(table, &mysql_columns_priv_table_def)) + DBUG_RETURN(-1); + table->use_all_columns(); table->field[0]->store(combo.host.str,combo.host.length, system_charset_info); @@ -3104,6 +3557,7 @@ static int replace_column_table(GRANT_TABLE *g_t, system_charset_info); /* Get length of 4 first key parts */ + key_part= table->key_info->key_part; key_prefix_length= (key_part[0].store_length + key_part[1].store_length + key_part[2].store_length + key_part[3].store_length); key_copy(key, table->record[0], table->key_info, key_prefix_length); @@ -3305,8 +3759,12 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, int error=0; ulong store_table_rights, store_col_rights; uchar user_key[MAX_KEY_LENGTH]; + Acl_table_intact table_intact; DBUG_ENTER("replace_table_table"); + if (table_intact.check(table, &mysql_tables_priv_table_def)) + DBUG_RETURN(-1); + get_grantor(thd, grantor); /* The following should always succeed as new users are created before @@ -3429,6 +3887,7 @@ static int replace_routine_table(THD *thd, GRANT_NAME *grant_name, int old_row_exists= 1; int error=0; ulong store_proc_rights; + Acl_table_intact table_intact; DBUG_ENTER("replace_routine_table"); if (!initialized) @@ -3437,6 +3896,9 @@ static int replace_routine_table(THD *thd, GRANT_NAME *grant_name, DBUG_RETURN(-1); } + if (table_intact.check(table, &mysql_procs_priv_table_def)) + DBUG_RETURN(-1); + get_grantor(thd, grantor); /* New users are created before this function is called. @@ -6366,9 +6828,16 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, int result= 0; int found; int ret; + Acl_table_intact table_intact; DBUG_ENTER("handle_grant_data"); /* Handle user table. */ + if (table_intact.check(tables[0].table, &mysql_user_table_def)) + { + result= -1; + goto end; + } + if ((found= handle_grant_table(tables, 0, drop, user_from, user_to)) < 0) { /* Handle of table failed, don't touch the in-memory array. */ @@ -6393,6 +6862,12 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } /* Handle db table. */ + if (table_intact.check(tables[1].table, &mysql_db_table_def)) + { + result= -1; + goto end; + } + if ((found= handle_grant_table(tables, 1, drop, user_from, user_to)) < 0) { /* Handle of table failed, don't touch the in-memory array. */ @@ -6417,6 +6892,12 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } /* Handle stored routines table. */ + if (table_intact.check(tables[4].table, &mysql_procs_priv_table_def)) + { + result= -1; + goto end; + } + if ((found= handle_grant_table(tables, 4, drop, user_from, user_to)) < 0) { /* Handle of table failed, don't touch in-memory array. */ @@ -6457,6 +6938,12 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } /* Handle tables table. */ + if (table_intact.check(tables[2].table, &mysql_tables_priv_table_def)) + { + result= -1; + goto end; + } + if ((found= handle_grant_table(tables, 2, drop, user_from, user_to)) < 0) { /* Handle of table failed, don't touch columns and in-memory array. */ @@ -6473,6 +6960,12 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, } /* Handle columns table. */ + if (table_intact.check(tables[3].table, &mysql_columns_priv_table_def)) + { + result= -1; + goto end; + } + if ((found= handle_grant_table(tables, 3, drop, user_from, user_to)) < 0) { /* Handle of table failed, don't touch the in-memory array. */ @@ -6493,6 +6986,12 @@ static int handle_grant_data(TABLE_LIST *tables, bool drop, /* Handle proxies_priv table. */ if (tables[5].table) { + if (table_intact.check(tables[5].table, &mysql_proxies_priv_table_def)) + { + result= -1; + goto end; + } + if ((found= handle_grant_table(tables, 5, drop, user_from, user_to)) < 0) { /* Handle of table failed, don't touch the in-memory array. */ diff --git a/sql/sql_acl.h b/sql/sql_acl.h index 050649d39bcd6..8718c6feae91b 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -1,7 +1,7 @@ #ifndef SQL_ACL_INCLUDED #define SQL_ACL_INCLUDED -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2016, 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 @@ -143,6 +143,53 @@ (((A) & ALTER_PROC_ACL) >> 23) | \ (((A) & GRANT_ACL) >> 8)) +enum mysql_user_table_field +{ + MYSQL_USER_FIELD_HOST = 0, + MYSQL_USER_FIELD_USER, + MYSQL_USER_FIELD_PASSWORD, + MYSQL_USER_FIELD_SELECT_PRIV, + MYSQL_USER_FIELD_INSERT_PRIV, + MYSQL_USER_FIELD_UPDATE_PRIV, + MYSQL_USER_FIELD_DELETE_PRIV, + MYSQL_USER_FIELD_CREATE_PRIV, + MYSQL_USER_FIELD_DROP_PRIV, + MYSQL_USER_FIELD_RELOAD_PRIV, + MYSQL_USER_FIELD_SHUTDOWN_PRIV, + MYSQL_USER_FIELD_PROCESS_PRIV, + MYSQL_USER_FIELD_FILE_PRIV, + MYSQL_USER_FIELD_GRANT_PRIV, + MYSQL_USER_FIELD_REFERENCES_PRIV, + MYSQL_USER_FIELD_INDEX_PRIV, + MYSQL_USER_FIELD_ALTER_PRIV, + MYSQL_USER_FIELD_SHOW_DB_PRIV, + MYSQL_USER_FIELD_SUPER_PRIV, + MYSQL_USER_FIELD_CREATE_TMP_TABLE_PRIV, + MYSQL_USER_FIELD_LOCK_TABLES_PRIV, + MYSQL_USER_FIELD_EXECUTE_PRIV, + MYSQL_USER_FIELD_REPL_SLAVE_PRIV, + MYSQL_USER_FIELD_REPL_CLIENT_PRIV, + MYSQL_USER_FIELD_CREATE_VIEW_PRIV, + MYSQL_USER_FIELD_SHOW_VIEW_PRIV, + MYSQL_USER_FIELD_CREATE_ROUTINE_PRIV, + MYSQL_USER_FIELD_ALTER_ROUTINE_PRIV, + MYSQL_USER_FIELD_CREATE_USER_PRIV, + MYSQL_USER_FIELD_EVENT_PRIV, + MYSQL_USER_FIELD_TRIGGER_PRIV, + MYSQL_USER_FIELD_CREATE_TABLESPACE_PRIV, + MYSQL_USER_FIELD_SSL_TYPE, + MYSQL_USER_FIELD_SSL_CIPHER, + MYSQL_USER_FIELD_X509_ISSUER, + MYSQL_USER_FIELD_X509_SUBJECT, + MYSQL_USER_FIELD_MAX_QUESTIONS, + MYSQL_USER_FIELD_MAX_UPDATES, + MYSQL_USER_FIELD_MAX_CONNECTIONS, + MYSQL_USER_FIELD_MAX_USER_CONNECTIONS, + MYSQL_USER_FIELD_PLUGIN, + MYSQL_USER_FIELD_AUTHENTICATION_STRING, + MYSQL_USER_FIELD_COUNT +}; + enum mysql_db_table_field { MYSQL_DB_FIELD_HOST = 0, @@ -170,6 +217,56 @@ enum mysql_db_table_field MYSQL_DB_FIELD_COUNT }; +enum mysql_proxies_priv_table_feild +{ + MYSQL_PROXIES_PRIV_FIELD_HOST = 0, + MYSQL_PROXIES_PRIV_FIELD_USER, + MYSQL_PROXIES_PRIV_FIELD_PROXIED_HOST, + MYSQL_PROXIES_PRIV_FIELD_PROXIED_USER, + MYSQL_PROXIES_PRIV_FIELD_WITH_GRANT, + MYSQL_PROXIES_PRIV_FIELD_GRANTOR, + MYSQL_PROXIES_PRIV_FIELD_TIMESTAMP, + MYSQL_PROXIES_PRIV_FIELD_COUNT +}; + +enum mysql_procs_priv_table_field +{ + MYSQL_PROCS_PRIV_FIELD_HOST = 0, + MYSQL_PROCS_PRIV_FIELD_DB, + MYSQL_PROCS_PRIV_FIELD_USER, + MYSQL_PROCS_PRIV_FIELD_ROUTINE_NAME, + MYSQL_PROCS_PRIV_FIELD_ROUTINE_TYPE, + MYSQL_PROCS_PRIV_FIELD_GRANTOR, + MYSQL_PROCS_PRIV_FIELD_PROC_PRIV, + MYSQL_PROCS_PRIV_FIELD_TIMESTAMP, + MYSQL_PROCS_PRIV_FIELD_COUNT +}; + +enum mysql_columns_priv_table_field +{ + MYSQL_COLUMNS_PRIV_FIELD_HOST = 0, + MYSQL_COLUMNS_PRIV_FIELD_DB, + MYSQL_COLUMNS_PRIV_FIELD_USER, + MYSQL_COLUMNS_PRIV_FIELD_TABLE_NAME, + MYSQL_COLUMNS_PRIV_FIELD_COLUMN_NAME, + MYSQL_COLUMNS_PRIV_FIELD_TIMESTAMP, + MYSQL_COLUMNS_PRIV_FIELD_COLUMN_PRIV, + MYSQL_COLUMNS_PRIV_FIELD_COUNT +}; + +enum mysql_tables_priv_table_field +{ + MYSQL_TABLES_PRIV_FIELD_HOST = 0, + MYSQL_TABLES_PRIV_FIELD_DB, + MYSQL_TABLES_PRIV_FIELD_USER, + MYSQL_TABLES_PRIV_FIELD_TABLE_NAME, + MYSQL_TABLES_PRIV_FIELD_GRANTOR, + MYSQL_TABLES_PRIV_FIELD_TIMESTAMP, + MYSQL_TABLES_PRIV_FIELD_TABLE_PRIV, + MYSQL_TABLES_PRIV_FIELD_COLUMN_PRIV, + MYSQL_TABLES_PRIV_FIELD_COUNT +}; + extern const TABLE_FIELD_DEF mysql_db_table_def; extern bool mysql_user_table_is_in_short_password_format; diff --git a/sql/table.cc b/sql/table.cc index 750b870da75f9..5bc3ccdbf39c6 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2016, 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 @@ -2998,11 +2998,7 @@ bool check_column_name(const char *name) and type) @retval FALSE OK - @retval TRUE There was an error. An error message is output - to the error log. We do not push an error - message into the error stack because this - function is currently only called at start up, - and such errors never reach the user. + @retval TRUE There was an error. */ bool @@ -3091,28 +3087,28 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def) if (strncmp(sql_type.c_ptr_safe(), field_def->type.str, field_def->type.length - 1)) { - report_error(0, "Incorrect definition of table %s.%s: " - "expected column '%s' at position %d to have type " - "%s, found type %s.", table->s->db.str, table->alias, - field_def->name.str, i, field_def->type.str, + report_error(ER_CANNOT_LOAD_FROM_TABLE, "Incorrect definition of " + "table %s.%s: expected column '%s' at position %d to " + "have type %s, found type %s.", table->s->db.str, + table->alias, field_def->name.str, i, field_def->type.str, sql_type.c_ptr_safe()); error= TRUE; } else if (field_def->cset.str && !field->has_charset()) { - report_error(0, "Incorrect definition of table %s.%s: " - "expected the type of column '%s' at position %d " - "to have character set '%s' but the type has no " - "character set.", table->s->db.str, table->alias, + report_error(ER_CANNOT_LOAD_FROM_TABLE, "Incorrect definition of " + "table %s.%s: expected the type of column '%s' at " + "position %d to have character set '%s' but the type " + "has no character set.", table->s->db.str, table->alias, field_def->name.str, i, field_def->cset.str); error= TRUE; } else if (field_def->cset.str && strcmp(field->charset()->csname, field_def->cset.str)) { - report_error(0, "Incorrect definition of table %s.%s: " - "expected the type of column '%s' at position %d " - "to have character set '%s' but found " + report_error(ER_CANNOT_LOAD_FROM_TABLE, "Incorrect definition of " + "table %s.%s: expected the type of column '%s' at " + "position %d to have character set '%s' but found " "character set '%s'.", table->s->db.str, table->alias, field_def->name.str, i, field_def->cset.str, field->charset()->csname); @@ -3121,11 +3117,11 @@ Table_check_intact::check(TABLE *table, const TABLE_FIELD_DEF *table_def) } else { - report_error(0, "Incorrect definition of table %s.%s: " - "expected column '%s' at position %d to have type %s " - " but the column is not found.", - table->s->db.str, table->alias, - field_def->name.str, i, field_def->type.str); + report_error(ER_CANNOT_LOAD_FROM_TABLE, "Incorrect definition of " + "table %s.%s: expected column '%s' at position %d to " + "have type %s but the column is not found.", + table->s->db.str, table->alias, field_def->name.str, i, + field_def->type.str); error= TRUE; } } From 251e82c2b5da9086bb66ecdfb5ac2745e5a6c956 Mon Sep 17 00:00:00 2001 From: "mysql-builder@oracle.com" <> Date: Fri, 25 Nov 2016 11:03:44 +0100 Subject: [PATCH 10/54] From ab5932f851da38d05bd1e401467ed197bdc2836d Mon Sep 17 00:00:00 2001 From: Balasubramanian Kandasamy Date: Mon, 28 Nov 2016 16:38:03 +0530 Subject: [PATCH 11/54] Bug#25159791 BASEDIR: COMMAND NOT FOUND ERROR WHILE STARTING SERVER WITH INIT SCRIPTS --- packaging/rpm-oel/mysql-systemd-start | 2 +- packaging/rpm-oel/mysql.init | 6 +++--- packaging/rpm-sles/mysql.init | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packaging/rpm-oel/mysql-systemd-start b/packaging/rpm-oel/mysql-systemd-start index af6e906efe135..c744bdceeb4d9 100644 --- a/packaging/rpm-oel/mysql-systemd-start +++ b/packaging/rpm-oel/mysql-systemd-start @@ -22,7 +22,7 @@ install_db () { datadir=$(get_option mysqld datadir "/var/lib/mysql") # Restore log, dir, perms and SELinux contexts - if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(dirname "$datadir")" = "x/var/lib" ]; then install -d -m 0755 -omysql -gmysql "$datadir" || exit 1 fi log=/var/log/mysqld.log diff --git a/packaging/rpm-oel/mysql.init b/packaging/rpm-oel/mysql.init index 50d1bba017dea..c3bbb277b91e7 100644 --- a/packaging/rpm-oel/mysql.init +++ b/packaging/rpm-oel/mysql.init @@ -76,10 +76,10 @@ start(){ [ -x /sbin/restorecon ] && /sbin/restorecon "$errlogfile" if [ ! -d "$datadir/mysql" ] ; then # First, make sure $datadir is there with correct permissions - if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(dirname "$datadir")" = "x/var/lib" ]; then install -d -m0755 -omysql -gmysql "$datadir" || exit 1 fi - if [ ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + if [ ! -h "$datadir" -a "x$(dirname "$datadir")" = "x/var/lib" ]; then chown mysql:mysql "$datadir" chmod 0755 "$datadir" fi @@ -99,7 +99,7 @@ start(){ return $ret fi fi - if [ ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + if [ ! -h "$datadir" -a "x$(dirname "$datadir")" = "x/var/lib" ]; then chown mysql:mysql "$datadir" chmod 0755 "$datadir" fi diff --git a/packaging/rpm-sles/mysql.init b/packaging/rpm-sles/mysql.init index 25762d9bee263..62f2a62e1b970 100644 --- a/packaging/rpm-sles/mysql.init +++ b/packaging/rpm-sles/mysql.init @@ -57,7 +57,7 @@ install_db () { logfile=$(get_option mysqld_safe log-error "/var/log/mysql/mysqld.log") # Restore log, dir, perms and SELinux contexts - if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(basedir "$datadir")" = "x/var/lib" ]; then + if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(dirname "$datadir")" = "x/var/lib" ]; then install -d -m 0755 -omysql -gmysql "$datadir" || return 1 fi From 8f297058512e6744b8d9f0bafe35689c702fce67 Mon Sep 17 00:00:00 2001 From: Shishir Jaiswal Date: Tue, 29 Nov 2016 11:19:30 +0530 Subject: [PATCH 12/54] Bug#24449090 - BUFFER OVERFLOW IN FUNCTION DUPL DESCRIPTION =========== Performing a pattern match of a Regex resulting into a very large string, leads to crash due to failed realloc(). ANALYSIS ======== dupl() calls enlarge(). It in turn calls realloc() for pointer p->strip. This eventually fails due to OOM. However we are still using the same pointer in memcpy() causing a SEGFAULT! FIX === 1) In dupl(), checking for error code (which would be set if realloc fails) immediately after call to enlarge(). Returning now with this error code. 2) Handling the same in the caller functions. --- regex/regcomp.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/regex/regcomp.c b/regex/regcomp.c index b1074a1d79ccd..e7feb9301e625 100644 --- a/regex/regcomp.c +++ b/regex/regcomp.c @@ -3,7 +3,7 @@ This file was modified by Oracle on 2015-05-18 for 32-bit compatibility. - Modifications copyright (c) 2015, Oracle and/or its affiliates. All rights + Modifications copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. */ #include @@ -551,6 +551,8 @@ int starordinary; /* is a leading * an ordinary character? */ assert(OP(p->strip[p->pbegin[i]]) == OLPAREN); assert(OP(p->strip[p->pend[i]]) == ORPAREN); (void) dupl(p, p->pbegin[i]+1, p->pend[i]); + if (p->error != 0) + break; /* purecov: inspected */ EMIT(O_BACK, i); } else SETERROR(REG_ESUBREG); @@ -1031,6 +1033,8 @@ int to; /* to this number of times (maybe RE_INFINITY) */ AHEAD(THERE()); /* ...so fix it */ ASTERN(O_CH, THERETHERE()); copy = dupl(p, start+1, finish+1); + if (p->error != 0) + return; /* purecov: inspected */ assert(copy == finish+4); repeat(p, copy, 1, to-1); break; @@ -1040,10 +1044,14 @@ int to; /* to this number of times (maybe RE_INFINITY) */ break; case REP(N, N): /* as xx{m-1,n-1} */ copy = dupl(p, start, finish); + if (p->error != 0) + return; repeat(p, copy, from-1, to-1); break; case REP(N, INF): /* as xx{n-1,INF} */ copy = dupl(p, start, finish); + if (p->error != 0) + return; /* purecov: inspected */ repeat(p, copy, from-1, to); break; default: /* "can't happen" */ @@ -1366,6 +1374,9 @@ sopno finish; /* to this less one */ if (len == 0) return(ret); enlarge(p, p->ssize + len); /* this many unexpected additions */ + if (p->error != 0) + return(p->error); + assert(p->ssize >= p->slen + len); (void) memcpy((char *)(p->strip + p->slen), (char *)(p->strip + start), (size_t)len*sizeof(sop)); @@ -1482,6 +1493,14 @@ register sopno size; if (p->ssize >= size) return; + DBUG_EXECUTE_IF("bug24449090_simulate_oom", + { + p->strip= NULL; + p->ssize= 0; + SETERROR(REG_ESPACE); + return; + }); + sp = (sop *)realloc(p->strip, size*sizeof(sop)); if (sp == NULL) { SETERROR(REG_ESPACE); From 52b0c8146b1ae84a6c3fa1a20aa41736df485a46 Mon Sep 17 00:00:00 2001 From: Shishir Jaiswal Date: Tue, 29 Nov 2016 11:26:25 +0530 Subject: [PATCH 13/54] Bug#24449076 - INTEGER OVERFLOW IN FUNCTION DOINSERT DESCRIPTION =========== Performing a pattern match of a Regex resulting into a very large string, leads to crash due to integer wraparound. ANALYSIS ======== doinsert() - The length calculated here (to copy the number of bytes) comes out to be too large to be stored in the "int" variable 'length'. We need to ensure that the variable can accommodate large lengths. FIX === 'length' in doinsert() is now defined as of type "size_t" instead of "int" --- regex/regcomp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regex/regcomp.c b/regex/regcomp.c index e7feb9301e625..7c450db07b7e0 100644 --- a/regex/regcomp.c +++ b/regex/regcomp.c @@ -1449,7 +1449,7 @@ sopno pos; } } { - int length=(HERE()-pos-1)*sizeof(sop); + size_t length=(HERE()-pos-1)*sizeof(sop); bmove_upp((uchar *) &p->strip[pos+1]+length, (uchar *) &p->strip[pos]+length, length); From 68b88afb0c7b65e36d27ebca05bd2e354840f2cf Mon Sep 17 00:00:00 2001 From: Shishir Jaiswal Date: Sun, 4 Dec 2016 18:44:51 +0530 Subject: [PATCH 14/54] Bug#24449090 - BUFFER OVERFLOW IN FUNCTION DUPL Post-push fix for memory leak in the code inside DBUG_EXECUTE_IF("bug24449090_simulate_oom",...); --- regex/regcomp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/regex/regcomp.c b/regex/regcomp.c index 7c450db07b7e0..13275237d2a63 100644 --- a/regex/regcomp.c +++ b/regex/regcomp.c @@ -1495,6 +1495,7 @@ register sopno size; DBUG_EXECUTE_IF("bug24449090_simulate_oom", { + free(p->strip); p->strip= NULL; p->ssize= 0; SETERROR(REG_ESPACE); From 6786caed623a051a364a73549181806c9d6ca757 Mon Sep 17 00:00:00 2001 From: Pavan Naik Date: Mon, 5 Dec 2016 10:17:40 +0530 Subject: [PATCH 15/54] BUG#25147154 : MTR TRIES TO COPY CONTENTS FROM /TMP/DATA Description : ============= When a MTR test run is started, it initializes the server and creates the datadir under '$MYSQL_TEST_DIR/var'('/tmp/var' or '/dev/shm/var' if --mem option is used) location and then copies it to the datadir location of server(s). If $parallel == 1, datadir location of the server is '$MYSQL_TEST_DIR/var/data'. If $parallel > 1, datadir location of any server is '$MYSQL_TEST_DIR/var//data'. This is the reason MTR searches for the initialized datadir in 2 locations('$opt_vardir' and '$opt_vardir/..') from the current vardir location.. But this can cause few problems. If a directory with the name 'data' already exists under '$MYSQL_TEST_DIR' and if the MTR run is started with parallel value 1, then 1. copytree($install_db, '$opt_vardir/..') command will fail if the user doesn't have the access permission to '$MYSQL_TEST_DIR/data' directory. 2. Unnecessary contents from '$MYSQL_TEST_DIR/data' directory will be copied to server datadir location and this might affect the server startup. Fix : ===== Depending on the $parallel value decide whether the path for the initialize datadir is "$opt_vardir"(i.e $parallel = 1) or "$opt_vardir/.."(i.e $parallel > 1). Reviewed-by: Deepa Dixit Reviewed-by: Srikanth B R RB: 14773 --- mysql-test/mysql-test-run.pl | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 3eb70c1bdb9b4..86d37a5683564 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -5388,16 +5388,14 @@ ($) my $mysqld_basedir= $mysqld->value('basedir'); if ( $basedir eq $mysqld_basedir ) { - if (! $opt_start_dirty) # If dirty, keep possibly grown system db + if (!$opt_start_dirty) # If dirty, keep possibly grown system db { - # Copy datadir from installed system db - for my $path ( "$opt_vardir", "$opt_vardir/..") { - my $install_db= "$path/install.db"; - copytree($install_db, $datadir) - if -d $install_db; - } - mtr_error("Failed to copy system db to '$datadir'") - unless -d $datadir; + # Copy datadir from installed system db + my $path= ($opt_parallel == 1) ? "$opt_vardir" : "$opt_vardir/.."; + my $install_db= "$path/install.db"; + copytree($install_db, $datadir) if -d $install_db; + mtr_error("Failed to copy system db to '$datadir'") + unless -d $datadir; } } else From 6722699551c8a63a4a7d5d76d116c049fabbbe51 Mon Sep 17 00:00:00 2001 From: Terje Rosten Date: Fri, 2 Dec 2016 13:33:44 +0100 Subject: [PATCH 16/54] Bug#22240513 REMOVE GITIGNORE / BZRIGNORE FROM OFFICIAL RELEASE Add .gitattributes to let git archive ignore .gitignore. --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000..596615322fb3e --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +.gitattributes export-ignore +.gitignore export-ignore From dafbdc788a1fe551990c736daaf2a39998f4cbc0 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Mon, 5 Dec 2016 15:36:23 +0200 Subject: [PATCH 17/54] Bug #25111907: XML TEST FAILS WITH UNDEFINED BEHAVIOR The XML parser position stack for each level is with a fixed depth. So a bounds check was done to ensure that this depth is not exceeded. But it was off by one (i.e. the size of the array was a valid index). Fixed by decreasing the allowable depth by one to match the maximum number of elements in the position stack. --- sql/item_xmlfunc.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index 2c8aab83ed996..31cd4fdd170eb 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2005, 2016, 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 @@ -2695,9 +2695,9 @@ int xml_enter(MY_XML_PARSER *st,const char *attr, size_t len) node.parent= data->parent; // Set parent for the new node to old parent data->parent= numnodes; // Remember current node as new parent - DBUG_ASSERT(data->level <= MAX_LEVEL); + DBUG_ASSERT(data->level < MAX_LEVEL); data->pos[data->level]= numnodes; - if (data->level < MAX_LEVEL) + if (data->level < MAX_LEVEL - 1) node.level= data->level++; else return MY_XML_ERROR; From 9ccd55466d1384865768663dd6bf2b04e11ba774 Mon Sep 17 00:00:00 2001 From: Terje Rosten Date: Tue, 6 Dec 2016 08:35:26 +0100 Subject: [PATCH 18/54] BUG#13788154 INIT.D MYSQL SCRIPT CREATED BY MYSQL SOLARIS PACKAGE FAILS TO RUN DUE TO USE OF PIDOF pidof is Linuxism, prefer pgrep on other UNIX systems. --- support-files/CMakeLists.txt | 7 ++++++- support-files/mysql.server.sh | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt index 6aef51a5c169f..924f08dfc8351 100644 --- a/support-files/CMakeLists.txt +++ b/support-files/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2016, 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 @@ -48,6 +48,11 @@ FOREACH(inifile my-huge my-innodb-heavy-4G my-large my-medium my-small) ENDFOREACH() IF(UNIX) + IF(CMAKE_SYSTEM_NAME MATCHES "Linux") + SET (PIDOF "pidof") + ELSE() + SET (PIDOF "pgrep -d' ' -f") + ENDIF() SET(prefix ${CMAKE_INSTALL_PREFIX}) FOREACH(script mysqld_multi.server mysql-log-rotate binary-configure config.medium.ini config.small.ini config.huge.ini ndb-config-2-node.ini) diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index 909d33f877085..cb13d2f10ba6f 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -359,7 +359,7 @@ case "$mode" in fi else # Try to find appropriate mysqld process - mysqld_pid=`pidof $libexecdir/mysqld` + mysqld_pid=`@PIDOF@ $libexecdir/mysqld` # test if multiple pids exist pid_count=`echo $mysqld_pid | wc -w` From 30a59a8d78f10f738aef124fe6736851275192bd Mon Sep 17 00:00:00 2001 From: Sreeharsha Ramanavarapu Date: Tue, 13 Dec 2016 16:41:05 +0530 Subject: [PATCH 19/54] Bug #24595937: INCORRECT BEHAVIOR WHEN LOADING DATA TO VIEW Issue: ------ While using the LOAD statement to insert data into an updateable view, the check to verify whether a column is actually updatable is missing. Solution for 5.5 and 5.6: ------------------------- For a view whose column-list in specified in the LOAD command, this check is not performed. This fix adds the check. This is a partial backport of Bug#21097485. Solution for 5.7 and trunk: --------------------------- For a view whose column-list is specified in the LOAD command, this check is already performed. This fix adds the same check when no column-list is specified. --- mysql-test/r/loaddata.result | 2 +- mysql-test/t/loaddata.test | 2 +- sql/sql_load.cc | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result index 2d67d24bedd66..6942ec6b33287 100644 --- a/mysql-test/r/loaddata.result +++ b/mysql-test/r/loaddata.result @@ -316,7 +316,7 @@ FIELDS ESCAPED BY '\\' TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' (c0, c2); -ERROR HY000: Invalid column reference (v2.c0) in LOAD DATA +ERROR HY000: Column 'c0' is not updatable LOAD DATA INFILE '../../std_data/bug35469.dat' INTO TABLE v3 FIELDS ESCAPED BY '\\' diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index aa7be52484e43..db21058daea91 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -292,7 +292,7 @@ SELECT * FROM v2; DELETE FROM t1; --echo ---error ER_LOAD_DATA_INVALID_COLUMN +--error ER_NONUPDATEABLE_COLUMN LOAD DATA INFILE '../../std_data/bug35469.dat' INTO TABLE v2 FIELDS ESCAPED BY '\\' TERMINATED BY ',' diff --git a/sql/sql_load.cc b/sql/sql_load.cc index c084e5e38390b..c28c7cdb2db72 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -296,6 +296,24 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, setup_fields(thd, 0, set_fields, MARK_COLUMNS_WRITE, 0, 0) || check_that_all_fields_are_given_values(thd, table, table_list)) DBUG_RETURN(TRUE); + + /* + Special updatability test is needed because fields_vars may contain + a mix of column references and user variables. + */ + Item *item; + List_iterator it(fields_vars); + while ((item= it++)) + { + if ((item->type() == Item::FIELD_ITEM || + item->type() == Item::REF_ITEM) && + item->filed_for_view_update() == NULL) + { + my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name); + DBUG_RETURN(true); + } + } + /* Check whenever TIMESTAMP field with auto-set feature specified explicitly. From 1079066b22815b9c46a6689c93469c3af1fd88ff Mon Sep 17 00:00:00 2001 From: Terje Rosten Date: Mon, 19 Dec 2016 10:15:54 +0100 Subject: [PATCH 20/54] Bug#13344753 MYSQL_SECURE_INSTALLATION SCRIPT DOES NOT CHECK USER INPUT Loop until valid answer is given. Variants of y,yes and n,no and blank (meaning default) are considered valid. --- scripts/mysql_secure_installation.sh | 67 ++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 19 deletions(-) diff --git a/scripts/mysql_secure_installation.sh b/scripts/mysql_secure_installation.sh index c92cb1262df3f..236525c12cdfd 100644 --- a/scripts/mysql_secure_installation.sh +++ b/scripts/mysql_secure_installation.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2002, 2016, 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 @@ -33,6 +33,20 @@ set_echo_compat() { esac } +validate_reply () { + ret=0 + if [ -z "$1" ]; then + reply=y + return $ret + fi + case $1 in + y|Y|yes|Yes|YES) reply=y ;; + n|N|no|No|NO) reply=n ;; + *) ret=1 ;; + esac + return $ret +} + prepare() { touch $config $command chmod 600 $config $command @@ -258,15 +272,18 @@ echo "Setting the root password ensures that nobody can log into the MySQL" echo "root user without the proper authorisation." echo -if [ $hadpass -eq 0 ]; then - echo $echo_n "Set root password? [Y/n] $echo_c" -else - echo "You already have a root password set, so you can safely answer 'n'." - echo - echo $echo_n "Change the root password? [Y/n] $echo_c" -fi +while true ; do + if [ $hadpass -eq 0 ]; then + echo $echo_n "Set root password? [Y/n] $echo_c" + else + echo "You already have a root password set, so you can safely answer 'n'." + echo + echo $echo_n "Change the root password? [Y/n] $echo_c" + fi + read reply + validate_reply $reply && break +done -read reply if [ "$reply" = "n" ]; then echo " ... skipping." else @@ -290,9 +307,11 @@ echo "go a bit smoother. You should remove them before moving into a" echo "production environment." echo -echo $echo_n "Remove anonymous users? [Y/n] $echo_c" - -read reply +while true ; do + echo $echo_n "Remove anonymous users? [Y/n] $echo_c" + read reply + validate_reply $reply && break +done if [ "$reply" = "n" ]; then echo " ... skipping." else @@ -308,9 +327,11 @@ echo echo "Normally, root should only be allowed to connect from 'localhost'. This" echo "ensures that someone cannot guess at the root password from the network." echo - -echo $echo_n "Disallow root login remotely? [Y/n] $echo_c" -read reply +while true ; do + echo $echo_n "Disallow root login remotely? [Y/n] $echo_c" + read reply + validate_reply $reply && break +done if [ "$reply" = "n" ]; then echo " ... skipping." else @@ -328,8 +349,12 @@ echo "access. This is also intended only for testing, and should be removed" echo "before moving into a production environment." echo -echo $echo_n "Remove test database and access to it? [Y/n] $echo_c" -read reply +while true ; do + echo $echo_n "Remove test database and access to it? [Y/n] $echo_c" + read reply + validate_reply $reply && break +done + if [ "$reply" = "n" ]; then echo " ... skipping." else @@ -346,8 +371,12 @@ echo "Reloading the privilege tables will ensure that all changes made so far" echo "will take effect immediately." echo -echo $echo_n "Reload privilege tables now? [Y/n] $echo_c" -read reply +while true ; do + echo $echo_n "Reload privilege tables now? [Y/n] $echo_c" + read reply + validate_reply $reply && break +done + if [ "$reply" = "n" ]; then echo " ... skipping." else From e00810b934fd495009c1b8d47446714bdbc0b249 Mon Sep 17 00:00:00 2001 From: Shishir Jaiswal Date: Thu, 22 Dec 2016 14:56:02 +0530 Subject: [PATCH 21/54] Bug#11751149 - TRYING TO START MYSQL WHILE ANOTHER INSTANCE IS STARTING: CONFUSING ERROR DESCRIPTION =========== When mysql server processes transactions but has not yet committed and shuts down abnormally (due to crash, external killing etc.), a recovery is due from Storage engine side which takes place the next time mysql server (either through mysqld or mysqld_safe) is run. While the 1st server is in mid of recovery, if another instance of mysqld_safe is made to run, it may result into 2nd instance killing the 1st one after a moment. ANALYSIS ======== In the "while true" loop, we've a check (which is done after the server stops) for the existence of pid file to enquire if it was a normal shutdown or not. If the file is absent, it means that the graceful exit of server had removed this file. However if the file is present, the scripts makes a plain assumption that this file is leftover of the "current" server. It misses to consider that it could be a valid pid file belonging to another running mysql server. We need to add more checks in the latter case. The script should extract the PID from this existing file and check if its running or not. If yes, it means an older instance of mysql server is running and hence the script should abort. FIX === Checking the status of process (alive or not) by adding a @CHECK_PID@ in such a case. Aborting if its alive. Detailed logic is as follows: - The mysqld_safe script would quit at start only as soon as it finds that there is an active PID i.e. a mysql server is already running. - The PID file creation takes place after InnoDb recovery, which means in rare case (when PID file isn't created yet) it may happen that more than 1 server can come up but even in that case others will have to wait till the 1st server has released the acquired InnoDb lock. In this case all these servers will either TIMEOUT waiting for InnoDb lock or after this they would find that the 1st server is already running (by reading $pid_file) and would abort. - Our core fix is that we now check the status of mysql server process (alive or not) after the server stops running within the loop of "run -> shutdown/kill/abort -> run ... ", so that only the script who owns the mysql server would be able to bring it down if required. NOTE ==== Removed the deletion of pid file and socket file from entry of the loop, as it may result in 2nd instance deleting these files created by 1st instance in RACE condition. Compensated this by deleting these files at end of the loop Reverted the changes made in patch to Bug#16776528. So after this patch is pushed, the concept of mysqld_safe.pid would go altogether. This was required as the script was deleting other instance's mysqld_safe.pid allowing multiple mysqld_safe instances to run in parallel. This patch would fix Bug#16776528 as well as the resources would be guarded anyway by InnoDb lock + our planned 5.7 patch. --- scripts/mysqld_safe.sh | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index a5c87a44e65c8..5148ecfc8880d 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -790,14 +790,23 @@ then fi if [ ! -h "$pid_file" ]; then rm -f "$pid_file" + if test -f "$pid_file"; then + log_error "Fatal error: Can't remove the pid file: +$pid_file. +Please remove the file manually and start $0 again; +mysqld daemon not started" + exit 1 + fi fi - if test -f "$pid_file" - then - log_error "Fatal error: Can't remove the pid file: -$pid_file -Please remove it manually and start $0 again; + if [ ! -h "$safe_mysql_unix_port" ]; then + rm -f "$safe_mysql_unix_port" + if test -f "$safe_mysql_unix_port"; then + log_error "Fatal error: Can't remove the socket file: +$safe_mysql_unix_port. +Please remove the file manually and start $0 again; mysqld daemon not started" - exit 1 + exit 1 + fi fi fi @@ -841,14 +850,6 @@ have_sleep=1 while true do - # Some extra safety - if [ ! -h "$safe_mysql_unix_port" ]; then - rm -f "$safe_mysql_unix_port" - fi - if [ ! -h "$pid_file" ]; then - rm -f "$pid_file" - fi - start_time=`date +%M%S` eval_log_error "$cmd" @@ -884,6 +885,13 @@ do if test ! -f "$pid_file" # This is removed if normal shutdown then break + else # self's mysqld crashed or other's mysqld running + PID=`cat "$pid_file"` + if @CHECK_PID@ + then # true when above pid belongs to a running mysqld process + log_error "A mysqld process with pid=$PID is already running. Aborting!!" + exit 1 + fi fi @@ -941,6 +949,12 @@ do I=`expr $I + 1` done fi + if [ ! -h "$pid_file" ]; then + rm -f "$pid_file" + fi + if [ ! -h "$safe_mysql_unix_port" ]; then + rm -f "$safe_mysql_unix_port" + fi log_notice "mysqld restarted" done From e7a3ccf6b1b1b41e0fa191d26e9e775517c6deee Mon Sep 17 00:00:00 2001 From: Horst Hunger Date: Tue, 3 Jan 2017 09:06:19 +0100 Subject: [PATCH 22/54] Bug#25335897: Modified the year of the date value from 2017 to 2037 in first event. --- mysql-test/r/events_2.result | 4 ++-- mysql-test/t/events_2.test | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/events_2.result b/mysql-test/r/events_2.result index 66ec00d73578f..31a501d48a6ed 100644 --- a/mysql-test/r/events_2.result +++ b/mysql-test/r/events_2.result @@ -1,10 +1,10 @@ drop database if exists events_test; create database events_test; use events_test; -create event e_26 on schedule at '2017-01-01 00:00:00' disable do set @a = 5; +create event e_26 on schedule at '2037-01-01 00:00:00' disable do set @a = 5; select db, name, body, definer, convert_tz(execute_at, 'UTC', 'SYSTEM'), on_completion from mysql.event; db name body definer convert_tz(execute_at, 'UTC', 'SYSTEM') on_completion -events_test e_26 set @a = 5 root@localhost 2017-01-01 00:00:00 DROP +events_test e_26 set @a = 5 root@localhost 2037-01-01 00:00:00 DROP drop event e_26; create event e_26 on schedule at NULL disable do set @a = 5; ERROR HY000: Incorrect AT value: 'NULL' diff --git a/mysql-test/t/events_2.test b/mysql-test/t/events_2.test index 3d609654b214e..d90ec100e4237 100644 --- a/mysql-test/t/events_2.test +++ b/mysql-test/t/events_2.test @@ -13,7 +13,7 @@ use events_test; # mysql.event intact checking end # -create event e_26 on schedule at '2017-01-01 00:00:00' disable do set @a = 5; +create event e_26 on schedule at '2037-01-01 00:00:00' disable do set @a = 5; select db, name, body, definer, convert_tz(execute_at, 'UTC', 'SYSTEM'), on_completion from mysql.event; drop event e_26; --error ER_WRONG_VALUE From 69bbf9efebf8df4af9cd049b052ef1474660257d Mon Sep 17 00:00:00 2001 From: Balasubramanian Kandasamy Date: Fri, 6 Jan 2017 18:15:13 +0530 Subject: [PATCH 23/54] Updated copyright year in user visible text --- README | 2 +- include/welcome_copyright_notice.h | 4 ++-- packaging/WiX/custom_ui.wxs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README b/README index 72cc70bbd163d..2a3230ac68516 100644 --- a/README +++ b/README @@ -5,7 +5,7 @@ For the avoidance of doubt, this particular copy of the software is released under the version 2 of the GNU General Public License. MySQL is brought to you by Oracle. -Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. License information can be found in the COPYING file. diff --git a/include/welcome_copyright_notice.h b/include/welcome_copyright_notice.h index 7b6c28c2f5665..0c17b5e650cff 100644 --- a/include/welcome_copyright_notice.h +++ b/include/welcome_copyright_notice.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ #ifndef _welcome_copyright_notice_h_ #define _welcome_copyright_notice_h_ -#define COPYRIGHT_NOTICE_CURRENT_YEAR "2016" +#define COPYRIGHT_NOTICE_CURRENT_YEAR "2017" /* This define specifies copyright notice which is displayed by every MySQL diff --git a/packaging/WiX/custom_ui.wxs b/packaging/WiX/custom_ui.wxs index e96ab0fe505e9..9475de92722e1 100644 --- a/packaging/WiX/custom_ui.wxs +++ b/packaging/WiX/custom_ui.wxs @@ -2,7 +2,7 @@ xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">