set -e

page_size_cnf="innodb_page_size=$1"
cnf_file="${MYSQLTEST_VARDIR}/my.cnf"
tmp_file="${MYSQL_TMP_DIR}/tmp.cnf"
cat $cnf_file | awk  -v page_size_cnf=$page_size_cnf '{print;} /\[mysqld\]/ {print page_size_cnf;}' > $tmp_file
mv $tmp_file $cnf_file


set -e

# Wait for file indicating the background load is finished
while ! [ -f $LOAD_DONE_INDICATOR_FILE ];
do
  sleep 1
done
# Remove the file now that we are done with it
rm $LOAD_DONE_INDICATOR_FILE


set -e

# Takes a full backup from server_1 to server_2 using xbstream

ibbackup_opt="--ibbackup=${MYSQL_XTRABACKUP}"
defaults_file_opt="--defaults-file=${MYSQLTEST_VARDIR}/my.cnf"
backup_dir="${MYSQLTEST_VARDIR}/backup"
dest_data_dir="${MYSQLTEST_VARDIR}/mysqld.2/data/"
xbstream_opt="--stream=${MYSQL_XBSTREAM}"
log_dir="${MYSQLTEST_VARDIR}/log"

mysql_dir=$(echo $MYSQL | awk '{print $1}' | xargs dirname)
PATH=$mysql_dir:$PATH

mkdir -p $backup_dir
rm -rf $backup_dir/*
# delete and recreate the dest dir to make sure all hidden files and directories (such as .rocksdb) are blown away
rm -rf $dest_data_dir/
mkdir $dest_data_dir

echo "innobackupex copy phase"
if ! $MYSQL_INNOBACKUPEX $defaults_file_opt --defaults-group=mysqld.1 $ibbackup_opt $xbstream_opt $backup_dir 2> $log_dir/xtrabackup_copy_log | $MYSQL_XBSTREAM -x --directory=$backup_dir
then
  tail $log_dir/xtrabackup_copy_log
  exit 1
fi

echo "innobackupex apply-log phase"
if ! $MYSQL_INNOBACKUPEX $ibbackup_opt $backup_dir --apply-log > $log_dir/xtrabackup_restore_log 2>&1
then
  tail $log_dir/xtrabackup_restore_log
  exit 1
fi

echo "innobackupex move-back phase"
if ! $MYSQL_INNOBACKUPEX $defaults_file_opt --defaults-group=mysqld.2 $ibbackup_opt $backup_dir --move-back > $log_dir/xtrabackup_moveback_log 2>&1
then
  tail $log_dir/xtrabackup_moveback_log
  exit 1
fi
cp $backup_dir/ib_logfile* $dest_data_dir


set -e

# Takes a full backup from server_1 to server_2 using xbstream

ibbackup_opt="--ibbackup=${MYSQL_XTRABACKUP}"
defaults_file_opt="--defaults-file=${MYSQLTEST_VARDIR}/my.cnf"
backup_dir="${MYSQLTEST_VARDIR}/backup"
dest_data_dir="${MYSQLTEST_VARDIR}/mysqld.2/data/"
xbstream_opt="--stream=${MYSQL_XBSTREAM} --slow_rm_chunk_delay=2 --slow_rm_chunk_percentage=20"
log_dir="${MYSQLTEST_VARDIR}/log"

mysql_dir=$(echo $MYSQL | awk '{print $1}' | xargs dirname)
PATH=$mysql_dir:$PATH

mkdir -p $backup_dir
rm -rf $backup_dir/*
# delete and recreate the dest dir to make sure all hidden files and directories (such as .rocksdb) are blown away
rm -rf $dest_data_dir/
mkdir $dest_data_dir

echo "innobackupex copy phase"
if ! $MYSQL_INNOBACKUPEX $defaults_file_opt --defaults-group=mysqld.1 $ibbackup_opt $xbstream_opt $backup_dir 2> $log_dir/xtrabackup_copy_log | $MYSQL_XBSTREAM -x --directory=$backup_dir
then
  tail $log_dir/xtrabackup_copy_log
  exit 1
fi

echo "innobackupex apply-log phase"
if ! $MYSQL_INNOBACKUPEX $ibbackup_opt $backup_dir --apply-log > $log_dir/xtrabackup_restore_log 2>&1
then
  tail $log_dir/xtrabackup_restore_log
  exit 1
fi

echo "innobackupex move-back phase"
if ! $MYSQL_INNOBACKUPEX $defaults_file_opt --defaults-group=mysqld.2 $ibbackup_opt $backup_dir --move-back > $log_dir/xtrabackup_moveback_log 2>&1
then
  tail $log_dir/xtrabackup_moveback_log
  exit 1
fi
cp $backup_dir/ib_logfile* $dest_data_dir


#!/bin/bash
touch $1/slocket_listen_kill_flag
sleep 3
rm $1/slocket_listen_kill_flag


#! /bin/bash

# This test requires a non-lowercase tmpdir directory on a case-sensitive
# filesystem.

d="$MYSQLTEST_VARDIR/tmp/MixedCase"
test -d "$d" || mkdir "$d"
rm -f "$d"/*


#! /bin/bash
#
# This test requires a non-lowercase tmpdir directory on a case-sensitive
# filesystem.

d="$MYSQLTEST_VARDIR/tmp/MixedCase"
test -d "$d" || mkdir "$d"
rm -f "$d"/*


#!/bin/sh

###########################################################################

# NOTE: this script returns 0 (success) even in case of failure (except for
# usage-error). This is because this script is executed under
# mysql-test-run[.pl] and it's better to examine particular problem in log
# file, than just having said that the test case has failed.

###########################################################################

basename=`basename "$0"`
dirname=`dirname "$0"`

###########################################################################

log_debug() {
  echo $1 >> $log_file
}

###########################################################################

if [ $# -ne 3 ]; then
  echo "Usage: $0 <client> <socket path> <test id>"
  exit 1
fi

client_exe="$1"
datadir_path="$2"
test_id="$3"
log_file="$MYSQLTEST_VARDIR/log/$test_id.script.log"
out_file="$MYSQLTEST_VARDIR/log/$test_id.listen.log"

log_debug "-- $basename: starting --"
log_debug "client_exe: '$client_exe'"
log_debug "datadir_path: '$datadir_path'"
log_debug "test_id: '$test_id'"
log_debug "log_file: '$log_file'"
log_debug "out_file: '$out_file'"

###########################################################################

if [ -z "$client_exe" ]; then
  log_debug "Invalid path to client executable ($client_exe)."
  exit 0;
fi

if [ ! -x "$client_exe" ]; then
  log_debug "Client by path '$client_exe' is not available."
  exit 0;
fi

###########################################################################

log_debug "--- running slocket listener --- "
python3 $client_exe $datadir_path > $out_file &

# perhaps the most important sleep of my life... without this, the test
# fails because the socket isn't opened before the test continues
sleep 1


#! /bin/bash
#
# Wrapper script for mysql_config to support multilib
#
#

# This command respects setarch, works on OL6/RHEL6 and later
bits=$(rpm --eval %__isa_bits)

case $bits in
    32|64) ;;
        *) bits=unknown ;;
esac

# Try mapping by uname if rpm command failed
if [ "$bits" = "unknown" ] ; then
    arch=$(uname -m)
    case $arch in
	x86_64|ppc64|ppc64le|aarch64|s390x|sparc64) bits=64 ;;
	i386|i486|i586|i686|pentium3|pentium4|athlon|ppc|s390|sparc) bits=32 ;;
	*) bits=unknown ;;
    esac
fi

if [ "$bits" == "unknown" ] ; then
    echo "$0: error: failed to determine isa bits on your arch."
    exit 1
fi

if [ -x /usr/bin/mysql_config-$bits ] ; then
    /usr/bin/mysql_config-$bits "$@"
else
    echo "$0: error: needed binary: /usr/bin/mysql_config-$bits is missing. Please check your MySQL installation."
    exit 1
fi


#! /bin/bash
#

/usr/lib/rpm/perl.prov $* |
sed -e '/perl(hostnames)/d' -e '/perl(lib::mtr.*/d' -e '/perl(lib::v1.*/d' -e '/perl(mtr_.*/d' -e '/perl(My::.*/d'


#! /bin/bash
#

/usr/lib/rpm/perl.req $* |
sed -e '/perl(GD)/d' -e '/perl(hostnames)/d' -e '/perl(lib::mtr.*/d' -e '/perl(lib::v1.*/d' -e '/perl(mtr_.*/d' -e '/perl(My::.*/d'


#!/bin/sh
#
# Copyright (c) 2008, 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
# 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
#
# Solaris post install script
#

#if [ /usr/man/bin/makewhatis ] ; then
#  /usr/man/bin/makewhatis "$BASEDIR/mysql/man"
#fi

mygroup=mysql
myuser=mysql
mydatadir=/var/lib/mysql
basedir=@@basedir@@
mysecurefiledir=/var/lib/mysql-files

if [ -n "$BASEDIR" ] ; then
  basedir="$BASEDIR"
fi

# What MySQL calls "basedir" and what pkgadd tools calls "basedir"
# is not the same thing. The default pkgadd base directory is /opt/mysql,
# the MySQL one "/opt/mysql/mysql".

mybasedir="$basedir/@@instdir@@"
mystart1="$mybasedir/support-files/mysql.server"
myinstdb="$mybasedir/scripts/mysql_install_db"
mystart=/etc/init.d/mysql

# Check: Is this a first installation, or an upgrade ?

if [ -d "$mydatadir/mysql" ] ; then
  :   # If the directory for system table files exists, we assume an upgrade.
else
  INSTALL=new  # This is a new installation, the directory will soon be created.
fi

# Create data directory if needed

[ -d "$mydatadir"       ] || mkdir -p -m 755 "$mydatadir" || exit 1
[ -d "$mydatadir/mysql" ] || mkdir "$mydatadir/mysql"     || exit 1
[ -d "$mydatadir/test"  ] || mkdir "$mydatadir/test"      || exit 1

# Set the data directory to the right user/group

chown -R $myuser:$mygroup $mydatadir

# Create securefile directory
[ -d "$mysecurefiledir"  ] || mkdir -p -m 770 "$mysecurefiledir"      || exit 1
chown -R $myuser:$mygroup $mysecurefiledir

# Solaris patch 119255 (somewhere around revision 42) changes the behaviour
# of pkgadd to set TMPDIR internally to a root-owned install directory.  This
# has the unfortunate side effect of breaking running mysql_install_db with
# the --user=mysql argument as mysqld uses TMPDIR if set, and is unable to
# write temporary tables to that directory.  To work around this issue, we
# create a subdirectory inside TMPDIR (if set) for mysqld to write to.
#
# Idea from Ben Hekster <heksterb@gmail.com> in bug#31164

if [ -n "$TMPDIR" ] ; then
  savetmpdir="$TMPDIR"
  TMPDIR="$TMPDIR/mysql.$$"
  export TMPDIR
  mkdir "$TMPDIR"
  chown $myuser:$mygroup "$TMPDIR"
fi

if [ -n "$INSTALL" ] ; then
  # We install/update the system tables
  (
    cd "$mybasedir"
    scripts/mysql_install_db \
	  --rpm \
	  --random-passwords \
	  --user=mysql \
	  --basedir="$mybasedir" \
	  --datadir=$mydatadir
  )
fi

if [ -n "$savetmpdir" ] ; then
  TMPDIR="$savetmpdir"
fi

# ----------------------------------------------------------------------

# Handle situation there is old start script installed already

# If old start script is a soft link, we just remove it
[ -h "$mystart" ] && rm -f "$mystart"

# If old start script is a file, we rename it
[ -f "$mystart" ] && mv -f "$mystart" "$mystart.old.$$"

# ----------------------------------------------------------------------

# We create a copy of an unmodified start script,
# as a reference for the one maybe modifying it

cp -f "$mystart1.in" "$mystart.in" || exit 1

# We rewrite some scripts

for script in "$mystart" "$mystart1" "$myinstdb" ; do
  script_in="$script.in"
  sed -e "s,@basedir@,$mybasedir,g" \
      -e "s,@datadir@,$mydatadir,g" "$script_in" > "$script"
  chmod u+x $script
done

rm -f "$mystart.in"

exit 0


#! /bin/sh
MEMC_VERSION=`git describe | tr '-' '_'`;
cat > .libs/config_version.h << EOF
#ifndef CONFIG_VERSION_H
#define CONFIG_VERSION_H

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "memcached $MEMC_VERSION"

/* Define to the version of this package. */
#define PACKAGE_VERSION "$MEMC_VERSION"

/* Version number of package */
#define VERSION "$MEMC_VERSION"

#endif // CONFIG_VERSION_H
EOF


#!/bin/sh
# Copyright (c) 1979, 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; see the file COPYING. If not, write to the
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston
# MA  02110-1301  USA.

echo "Warning: $0 is deprecated and will be removed in a future version.\n" 1>&2;

@bindir@/replace msqlConnect mysql_connect msqlListDBs  mysql_list_dbs msqlNumRows mysql_num_rows msqlFetchRow mysql_fetch_row msqlFetchField mysql_fetch_field msqlFreeResult mysql_free_result msqlListFields mysql_list_fields msqlListTables mysql_list_tables msqlErrMsg 'mysql_error(mysql)' msqlStoreResult mysql_store_result msqlQuery mysql_query msqlField mysql_field msqlSelect mysql_select msqlSelectDB mysql_select_db msqlNumFields mysql_num_fields msqlClose mysql_close msqlDataSeek mysql_data_seek m_field MYSQL_FIELD m_result MYSQL_RES m_row MYSQL_ROW msql mysql mSQL mySQL MSQL MYSQL msqlCreateDB mysql_create_db msqlDropDB mysql_drop_db msqlFieldSeek mysql_field_seek -- $*