Skip to content

Commit

Permalink
Bug#26328958 TEST FAILURE IN MAIN.BASEDIR WITH CUSTOM -DINSTALL_MYSQL…
Browse files Browse the repository at this point in the history
…SHAREDIR=

Background:

Cmake creates ${cmake_binary_dir}/sql/share/ regardless of
INSTALL_SHAREDIR setting, to "fix" this MTR sets --lc-messages-dir and
--basedir options.

mysqld in main.basedir runs without --basedir and --lc-messages-dir
options and breaks due to mismatch between compiled-in install layout
and sandbox layout.

Solution:

Make both source and build sandbox layout more identical to install
layout by moving sql/share/ to share/, such that
runtime_output_directory/ and share/ will have common parent
(${cmake_binary_dir}) like in install layout.

This make sense since WL#10441 as mysqld will find basedir and
lc-messages-dir itself, if cmake creates share directory in
${cmake_binary_dir}/ according to -DINSTALL_MYSQLSHAREDIR, things
would work out of box without options specified. This will work in
build sandbox and after "make install". In other words mysqld basedir
is moved from ${cmake_binary_dir}/sql/ to ${cmake_binary_dir}/ in
sandbox.

After change options --basedir and --lc-messages-dir can be removed
from MTR runs, and special cases in mysqld.cc can be removed too.
Search path "sql/share" is removed or adjusted.

Tests fragments that don't have stable output any longer have been
removed.

Basedir option is used by MTR to find "itself" in sandbox mode, hence
it can't be removed even if not used by mysqld. Variable is renamed
to #mtr_basedir in generated my.cnf.

Note:

This means errmsg-utf8.txt is moved from sql/share to share/,
take care when merging from older major versions.
  • Loading branch information
trosten committed Jul 7, 2017
1 parent 7e51e23 commit ae38a4c
Show file tree
Hide file tree
Showing 51 changed files with 65 additions and 121 deletions.
48 changes: 24 additions & 24 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2667,30 +2667,30 @@ mysql-test/bug36522.tar
mysql-test/t.log
mysql-test/tps.log
autom4te.cache
sql/share/czech
sql/share/danish
sql/share/dutch
sql/share/english
sql/share/estonian
sql/share/french
sql/share/german
sql/share/greek
sql/share/hungarian
sql/share/italian
sql/share/japanese
sql/share/japanese-sjis
sql/share/korean
sql/share/norwegian
sql/share/norwegian-ny
sql/share/polish
sql/share/portuguese
sql/share/romanian
sql/share/russian
sql/share/serbian
sql/share/slovak
sql/share/spanish
sql/share/swedish
sql/share/ukrainian
share/czech
share/danish
share/dutch
share/english
share/estonian
share/french
share/german
share/greek
share/hungarian
share/italian
share/japanese
share/japanese-sjis
share/korean
share/norwegian
share/norwegian-ny
share/polish
share/portuguese
share/romanian
share/russian
share/serbian
share/slovak
share/spanish
share/swedish
share/ukrainian
*.jar
*.dylib
*.stamp
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ ENDIF()

ADD_SUBDIRECTORY(client)
ADD_SUBDIRECTORY(utilities)
ADD_SUBDIRECTORY(sql/share)
ADD_SUBDIRECTORY(share)
ADD_SUBDIRECTORY(libservices)

IF(UNIX)
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/extra/rpl_tests/rpl_temporary.test
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ create temporary table `\E4\F6\FC\C4\D6\DC` (a int);
insert into `\E4\F6\FC\C4\D6\DC` values (1);
insert into t1 select * from `\E4\F6\FC\C4\D6\DC`
EOF
--exec $MYSQL --character-sets-dir=../sql/share/charsets/ --default-character-set=latin1 test < $MYSQLTEST_VARDIR/tmp/bug14157.sql
--exec $MYSQL --character-sets-dir=../share/charsets/ --default-character-set=latin1 test < $MYSQLTEST_VARDIR/tmp/bug14157.sql

sync_slave_with_master;
#connection slave;
Expand Down
1 change: 1 addition & 0 deletions mysql-test/include/mysqld--help.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ perl;
# their paths may vary:
@skipvars=qw/basedir open-files-limit general-log-file plugin-dir
pid-file slow-query-log-file
language lc-messages-dir
datadir slave-load-tmpdir tmpdir socket table-definition-cache table-open-cache
tls-version secure-file-priv/;

Expand Down
5 changes: 2 additions & 3 deletions mysql-test/lib/My/ConfigFactory.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ my @pre_rules=
);


my @share_locations= ("share/mysql", "sql/share", "share");
my @share_locations= ("share/mysql", "share");


sub get_basedir {
Expand Down Expand Up @@ -243,10 +243,9 @@ sub fix_ssl_server_key {
#
my @mysqld_rules=
(
{ 'basedir' => sub { return shift->{ARGS}->{basedir}; } },
{ '#mtr_basedir' => sub { return shift->{ARGS}->{basedir}; } },
{ 'tmpdir' => \&fix_tmpdir },
{ 'character-sets-dir' => \&fix_charset_dir },
{ 'lc-messages-dir' => \&fix_language },
{ 'datadir' => \&fix_datadir },
{ 'pid-file' => \&fix_pidfile },
{ '#host' => \&fix_host },
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/lib/My/Find.pm
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ sub my_find_file {
#
# Example:
# my $charset_set= my_find_dir($basedir,
# ["mysql/share","sql/share", "share"],
# ["mysql/share", "share"],
# ["charset"]);
# or
# my $charset_set= my_find_dir($basedir,
Expand Down
5 changes: 2 additions & 3 deletions mysql-test/lib/t/Find.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- cperl -*-

# Copyright (c) 2007 MySQL AB
# Use is subject to license terms.
# Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -44,7 +43,7 @@ $ENV{MTR_BUILD_DIR}= $mtr_build_dir;
print "=" x 40, "\n";

my $charset_dir= my_find_dir($basedir,
["share/mysql", "sql/share", "share"],
["share/mysql", "share"],
"charsets");
print "charset_dir: $charset_dir\n";
print "=" x 40, "\n";
15 changes: 5 additions & 10 deletions mysql-test/mysql-test-run.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1383,11 +1383,9 @@ sub command_line_setup {

# Look for language files and charsetsdir, use same share
$path_language= mtr_path_exists("$bindir/share/mysql",
"$bindir/sql/share",
"$bindir/share");
my $path_share= $path_language;
$path_charsetsdir = mtr_path_exists("$basedir/share/mysql/charsets",
"$basedir/sql/share/charsets",
"$basedir/share/charsets");

($auth_plugin)= find_plugin("auth_test_plugin", "plugin_output_directory");
Expand Down Expand Up @@ -2066,7 +2064,6 @@ sub collect_mysqld_features {
mtr_add_arg($args, "--log-syslog=0");
mtr_add_arg($args, "--datadir=%s", mixed_path($tmpdir));
mtr_add_arg($args, "--secure-file-priv=\"\"");
mtr_add_arg($args, "--lc-messages-dir=%s", $path_language);
mtr_add_arg($args, "--skip-grant-tables");
mtr_add_arg($args, "--verbose");
mtr_add_arg($args, "--help");
Expand Down Expand Up @@ -2207,7 +2204,7 @@ sub find_mysqld {
}

return my_find_bin($mysqld_basedir,
["runtime_output_directory", "sql", "libexec", "sbin", "bin"],
["runtime_output_directory", "libexec", "sbin", "bin"],
[@mysqld_names]);
}

Expand Down Expand Up @@ -3865,7 +3862,7 @@ sub mysql_install_db {
my ($mysqld, $datadir, $bootstrap_opts)= @_;

my $install_datadir= $datadir || $mysqld->value('datadir');
my $install_basedir= $mysqld->value('basedir');
my $install_basedir= $mysqld->value('#mtr_basedir');
my $install_chsdir= $mysqld->value('character-sets-dir');

mtr_report("Installing system database...");
Expand All @@ -3878,9 +3875,7 @@ sub mysql_install_db {
mtr_add_arg($args, "--loose-skip-ndbcluster");
mtr_add_arg($args, "--tmpdir=%s", "$opt_vardir/tmp/");
mtr_add_arg($args, "--core-file");
mtr_add_arg($args, "--basedir=%s", $mysqld->value('basedir'));
mtr_add_arg($args, "--datadir=%s", "$install_datadir");
mtr_add_arg($args, "--lc-messages-dir=%s", $mysqld->value('lc-messages-dir'));
mtr_add_arg($args, "--secure-file-priv=%s", "$opt_vardir");
# overwrite the buffer size to 24M for certain tests to pass
mtr_add_arg($args, "--innodb_buffer_pool_size=24M");
Expand Down Expand Up @@ -3963,7 +3958,7 @@ sub mysql_install_db {
}

my $path_sql= my_find_file($install_basedir,
["mysql", "sql/share", "share/mysql",
["mysql", "share/mysql",
"share", "scripts"],
"mysql_system_tables.sql",
NOT_REQUIRED);
Expand Down Expand Up @@ -5990,7 +5985,7 @@ ($$)

mtr_verbose(My::Options::toStr("mysqld_start", @$extra_opts));

my $exe= find_mysqld($mysqld->value('basedir'));
my $exe= find_mysqld($mysqld->value('#mtr_basedir'));
my $wait_for_pid_file= 1;

my $args;
Expand Down Expand Up @@ -6541,7 +6536,7 @@ ($)
}
}

my $mysqld_basedir= $mysqld->value('basedir');
my $mysqld_basedir= $mysqld->value('#mtr_basedir');
if ( $basedir eq $mysqld_basedir )
{
if (!$opt_start_dirty) # If dirty, keep possibly grown system db
Expand Down
2 changes: 0 additions & 2 deletions mysql-test/r/mysqld--help-notwin.result
Original file line number Diff line number Diff line change
Expand Up @@ -1369,10 +1369,8 @@ key-buffer-size 8388608
key-cache-age-threshold 300
key-cache-block-size 1024
key-cache-division-limit 100
language MYSQL_SHAREDIR/
large-pages FALSE
lc-messages en_US
lc-messages-dir MYSQL_SHAREDIR/
lc-time-names en_US
local-infile FALSE
lock-wait-timeout 31536000
Expand Down
2 changes: 0 additions & 2 deletions mysql-test/r/mysqld--help-win.result
Original file line number Diff line number Diff line change
Expand Up @@ -1366,9 +1366,7 @@ key-buffer-size 8388608
key-cache-age-threshold 300
key-cache-block-size 1024
key-cache-division-limit 100
language MYSQL_SHAREDIR/
lc-messages en_US
lc-messages-dir MYSQL_SHAREDIR/
lc-time-names en_US
local-infile FALSE
lock-wait-timeout 31536000
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/rpl_nogtid/t/rpl_temporary.test
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ create temporary table `\E4\F6\FC\C4\D6\DC` (a int);
insert into `\E4\F6\FC\C4\D6\DC` values (1);
insert into t1 select * from `\E4\F6\FC\C4\D6\DC`
EOF
--exec $MYSQL --character-sets-dir=../sql/share/charsets/ --default-character-set=latin1 test < $MYSQLTEST_VARDIR/tmp/bug14157.sql
--exec $MYSQL --character-sets-dir=../share/charsets/ --default-character-set=latin1 test < $MYSQLTEST_VARDIR/tmp/bug14157.sql

--source include/sync_slave_sql_with_master.inc
#connection slave;
Expand Down
17 changes: 0 additions & 17 deletions mysql-test/suite/sys_vars/r/lc_messages_dir_basic.result
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
select @@global.lc_messages_dir;
@@global.lc_messages_dir
MYSQL_SHAREDIR/
select @@session.lc_messages_dir;
ERROR HY000: Variable 'lc_messages_dir' is a GLOBAL variable
show global variables like 'lc_messages_dir';
Variable_name Value
lc_messages_dir MYSQL_SHAREDIR/
show session variables like 'lc_messages_dir';
Variable_name Value
lc_messages_dir MYSQL_SHAREDIR/
select * from performance_schema.global_variables where variable_name='lc_messages_dir';
VARIABLE_NAME VARIABLE_VALUE
lc_messages_dir MYSQL_SHAREDIR/
select * from performance_schema.session_variables where variable_name='lc_messages_dir';
VARIABLE_NAME VARIABLE_VALUE
lc_messages_dir MYSQL_SHAREDIR/
set global lc_messages_dir=1;
ERROR HY000: Variable 'lc_messages_dir' is a read only variable
set session lc_messages_dir=1;
Expand Down
18 changes: 0 additions & 18 deletions mysql-test/suite/sys_vars/t/lc_messages_dir_basic.test
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
#
# only global
#
--replace_result $MYSQL_SHAREDIR MYSQL_SHAREDIR
select @@global.lc_messages_dir;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.lc_messages_dir;
--replace_result $MYSQL_SHAREDIR MYSQL_SHAREDIR
show global variables like 'lc_messages_dir';
--replace_result $MYSQL_SHAREDIR MYSQL_SHAREDIR
show session variables like 'lc_messages_dir';
--disable_warnings
--replace_result $MYSQL_SHAREDIR MYSQL_SHAREDIR
select * from performance_schema.global_variables where variable_name='lc_messages_dir';
--replace_result $MYSQL_SHAREDIR MYSQL_SHAREDIR
select * from performance_schema.session_variables where variable_name='lc_messages_dir';
--enable_warnings

#
# show that it's read-only
#
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/t/charset.test
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ DROP DATABASE db21958734;
--source include/wait_until_disconnected.inc

--error 1
--exec $MYSQLD --datadir=../data --basedir=. --lc-messages-dir=$MYSQLTEST_VARDIR/../../sql/share/english --character-set-server=filename >$MYSQLTEST_VARDIR/log/mysqld_out_err.log 2>&1
--exec $MYSQLD --datadir=../data --basedir=. --lc-messages-dir=$MYSQLTEST_VARDIR/../../share/english --character-set-server=filename >$MYSQLTEST_VARDIR/log/mysqld_out_err.log 2>&1

--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
Expand Down
6 changes: 3 additions & 3 deletions sql/share/CMakeLists.txt → share/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2006, 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
Expand Down Expand Up @@ -46,7 +46,7 @@ SET(files
)

FOREACH (dir ${dirs})
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${dir}
INSTALL(DIRECTORY ${CMAKE_BINARY_DIR}/${INSTALL_MYSQLSHAREDIR}/${dir}
DESTINATION ${INSTALL_MYSQLSHAREDIR}
COMPONENT Server
)
Expand All @@ -60,7 +60,7 @@ INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/charsets

# Don't copy if we're building in-source.
IF (NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
CONFIGURE_FILE(dictionary.txt ${CMAKE_BINARY_DIR}/sql/share/dictionary.txt)
CONFIGURE_FILE(dictionary.txt ${CMAKE_BINARY_DIR}/${INSTALL_MYSQLSHAREDIR}/dictionary.txt)
ENDIF()

INSTALL(FILES ${files}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 2 additions & 14 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7894,7 +7894,7 @@ static int mysql_init_variables()

// On windows the basedir will always be one level up from where
// the executable is located. E.g. <basedir>/bin/mysqld.exe in a
// package, or <basedir=sql>/<buildconfig>/mysqld.exe for a
// package, or <basedir>/runtime_output_directory/<buildconfig>/mysqld.exe for a
// sandbox build.
strcat(prg_dev,"/../"); // Remove containing directory to get base dir
cleanup_dirname(mysql_home, prg_dev);
Expand All @@ -7909,7 +7909,6 @@ static int mysql_init_variables()
{
mysql_home[strlen(mysql_home) - 1]= '\0'; // remove trailing
dirname_part(cmake_binary_dir, mysql_home, &dlen);
strcat(cmake_binary_dir, "sql\\");
strmake(mysql_home, cmake_binary_dir, sizeof(mysql_home) - 1);
}
// The sql_print_information below outputs nothing ??
Expand All @@ -7926,23 +7925,12 @@ static int mysql_init_variables()
char progdir[FN_REFLEN];
size_t dlen= 0;
dirname_part(progdir, my_progname, &dlen);
if (!strcmp(progdir + (dlen - 5), "/sql/"))
{
// Running in sandbox, set mysql_home to progdir (CMAKE_BINARY_DIR/sql)
if (!opt_help)
{
sql_print_information("Running in sandbox, basedir set to %s",
progdir);
}
strmake(mysql_home, progdir, sizeof(mysql_home) - 1);
}
else if (dlen > 26U &&
if (dlen > 26U &&
!strcmp(progdir + (dlen - 26), "/runtime_output_directory/"))
{
char cmake_binary_dir[FN_REFLEN];
progdir[strlen(progdir) - 1]= '\0'; // remove trailing "/"
dirname_part(cmake_binary_dir, progdir, &dlen);
strcat(cmake_binary_dir, "sql/");
strmake(mysql_home, cmake_binary_dir, sizeof(mysql_home) - 1);
}
else
Expand Down
9 changes: 4 additions & 5 deletions storage/myisam/ftbench/ft-test-run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/sh

# Copyright (c) 2003, 2005, 2006 MySQL AB
# Use is subject to license terms
# Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
Expand Down Expand Up @@ -32,7 +31,7 @@ MYSQLADMIN=$ROOT/client/mysqladmin
SOCK=$DATA/mysql.sock
PID=$DATA/mysql.pid
H=../ftdefs.h
OPTS="--no-defaults --socket=$SOCK --character-sets-dir=$ROOT/sql/share/charsets"
OPTS="--no-defaults --socket=$SOCK --character-sets-dir=$ROOT/share/charsets"
DELAY=10

stop_myslqd()
Expand Down Expand Up @@ -68,7 +67,7 @@ for batch in t/* ; do
else
bk get -q $H
fi
OPTS="--defaults-file=$BASE/$batch/my.cnf --socket=$SOCK --character-sets-dir=$ROOT/sql/share/charsets"
OPTS="--defaults-file=$BASE/$batch/my.cnf --socket=$SOCK --character-sets-dir=$ROOT/share/charsets"
stop_myslqd
rm -f $MYSQLD
echo "building $batch"
Expand All @@ -84,7 +83,7 @@ for batch in t/* ; do

echo "=====================================" >> var/ft_test.log
$MYSQLD $OPTS --basedir=$BASE --pid-file=$PID \
--language=$ROOT/sql/share/english \
--language=$ROOT/share/english \
--skip-grant-tables --skip-innodb \
--skip-networking --tmpdir=$DATA >> var/ft_test.log 2>&1 &

Expand Down
Loading

0 comments on commit ae38a4c

Please sign in to comment.