Skip to content

Commit 4ffccff

Browse files
author
Nirbhay Choubey
committed
MDEV-6717 : wsrep_data_home_dir should default to @@datadir
Used mysql_real_data_home as wsrep_data_home_dir's default. Added a test case.
1 parent f3e95ca commit 4ffccff

File tree

4 files changed

+48
-32
lines changed

4 files changed

+48
-32
lines changed

mysql-test/suite/sys_vars/r/wsrep_data_home_dir_basic.result

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,58 @@
22
# wsrep_data_home_dir (readonly)
33
#
44
# default
5-
SELECT @@global.wsrep_data_home_dir;
6-
@@global.wsrep_data_home_dir
7-
5+
SELECT COUNT(@@global.wsrep_data_home_dir);
6+
COUNT(@@global.wsrep_data_home_dir)
7+
1
88

99
# scope
1010
SELECT @@session.wsrep_data_home_dir;
1111
ERROR HY000: Variable 'wsrep_data_home_dir' is a GLOBAL variable
1212
SET @@global.wsrep_data_home_dir='/tmp/data';
1313
ERROR HY000: Variable 'wsrep_data_home_dir' is a read only variable
14-
SELECT @@global.wsrep_data_home_dir;
15-
@@global.wsrep_data_home_dir
16-
14+
SELECT COUNT(@@global.wsrep_data_home_dir);
15+
COUNT(@@global.wsrep_data_home_dir)
16+
1
1717

1818
# valid values
1919
SET @@global.wsrep_data_home_dir='/tmp/data';
2020
ERROR HY000: Variable 'wsrep_data_home_dir' is a read only variable
21-
SELECT @@global.wsrep_data_home_dir;
22-
@@global.wsrep_data_home_dir
23-
21+
SELECT COUNT(@@global.wsrep_data_home_dir);
22+
COUNT(@@global.wsrep_data_home_dir)
23+
1
2424
SET @@global.wsrep_data_home_dir=junk-dir;
2525
ERROR HY000: Variable 'wsrep_data_home_dir' is a read only variable
26-
SELECT @@global.wsrep_data_home_dir;
27-
@@global.wsrep_data_home_dir
28-
26+
SELECT COUNT(@@global.wsrep_data_home_dir);
27+
COUNT(@@global.wsrep_data_home_dir)
28+
1
2929
SET @@global.wsrep_data_home_dir=junk/dir;
3030
ERROR HY000: Variable 'wsrep_data_home_dir' is a read only variable
31-
SELECT @@global.wsrep_data_home_dir;
32-
@@global.wsrep_data_home_dir
33-
31+
SELECT COUNT(@@global.wsrep_data_home_dir);
32+
COUNT(@@global.wsrep_data_home_dir)
33+
1
3434
SET @@global.wsrep_data_home_dir=OFF;
3535
ERROR HY000: Variable 'wsrep_data_home_dir' is a read only variable
36-
SELECT @@global.wsrep_data_home_dir;
37-
@@global.wsrep_data_home_dir
38-
36+
SELECT COUNT(@@global.wsrep_data_home_dir);
37+
COUNT(@@global.wsrep_data_home_dir)
38+
1
3939
SET @@global.wsrep_data_home_dir=default;
4040
ERROR HY000: Variable 'wsrep_data_home_dir' is a read only variable
41-
SELECT @@global.wsrep_data_home_dir;
42-
@@global.wsrep_data_home_dir
43-
41+
SELECT COUNT(@@global.wsrep_data_home_dir);
42+
COUNT(@@global.wsrep_data_home_dir)
43+
1
4444

4545
# invalid values
4646
SET @@global.wsrep_data_home_dir=NULL;
4747
ERROR HY000: Variable 'wsrep_data_home_dir' is a read only variable
48+
#
49+
# MDEV-6717 : wsrep_data_home_dir should default to @@datadir
50+
#
51+
SELECT @@GLOBAL.wsrep_data_home_dir = VARIABLE_VALUE FROM
52+
INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='datadir';
53+
@@GLOBAL.wsrep_data_home_dir = VARIABLE_VALUE
54+
1
55+
SELECT @@GLOBAL.wsrep_data_home_dir = VARIABLE_VALUE FROM
56+
INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='wsrep_data_home_dir';
57+
@@GLOBAL.wsrep_data_home_dir = VARIABLE_VALUE
58+
1
4859
# End of test

mysql-test/suite/sys_vars/t/wsrep_data_home_dir_basic.test

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,45 @@
55
--echo #
66

77
--echo # default
8-
SELECT @@global.wsrep_data_home_dir;
8+
SELECT COUNT(@@global.wsrep_data_home_dir);
99

1010
--echo
1111
--echo # scope
1212
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
1313
SELECT @@session.wsrep_data_home_dir;
1414
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
1515
SET @@global.wsrep_data_home_dir='/tmp/data';
16-
SELECT @@global.wsrep_data_home_dir;
16+
SELECT COUNT(@@global.wsrep_data_home_dir);
1717

1818
--echo
1919
--echo # valid values
2020
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
2121
SET @@global.wsrep_data_home_dir='/tmp/data';
22-
SELECT @@global.wsrep_data_home_dir;
22+
SELECT COUNT(@@global.wsrep_data_home_dir);
2323
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
2424
SET @@global.wsrep_data_home_dir=junk-dir;
25-
SELECT @@global.wsrep_data_home_dir;
25+
SELECT COUNT(@@global.wsrep_data_home_dir);
2626
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
2727
SET @@global.wsrep_data_home_dir=junk/dir;
28-
SELECT @@global.wsrep_data_home_dir;
28+
SELECT COUNT(@@global.wsrep_data_home_dir);
2929
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
3030
SET @@global.wsrep_data_home_dir=OFF;
31-
SELECT @@global.wsrep_data_home_dir;
31+
SELECT COUNT(@@global.wsrep_data_home_dir);
3232
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
3333
SET @@global.wsrep_data_home_dir=default;
34-
SELECT @@global.wsrep_data_home_dir;
34+
SELECT COUNT(@@global.wsrep_data_home_dir);
3535

3636
--echo
3737
--echo # invalid values
3838
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
3939
SET @@global.wsrep_data_home_dir=NULL;
4040

41+
--echo #
42+
--echo # MDEV-6717 : wsrep_data_home_dir should default to @@datadir
43+
--echo #
44+
SELECT @@GLOBAL.wsrep_data_home_dir = VARIABLE_VALUE FROM
45+
INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='datadir';
46+
SELECT @@GLOBAL.wsrep_data_home_dir = VARIABLE_VALUE FROM
47+
INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='wsrep_data_home_dir';
48+
4149
--echo # End of test

sql/sys_vars.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4506,7 +4506,7 @@ static Sys_var_charptr Sys_wsrep_provider_options(
45064506
static Sys_var_charptr Sys_wsrep_data_home_dir(
45074507
"wsrep_data_home_dir", "home directory for wsrep provider",
45084508
READ_ONLY GLOBAL_VAR(wsrep_data_home_dir), CMD_LINE(REQUIRED_ARG),
4509-
IN_FS_CHARSET, DEFAULT(""),
4509+
IN_FS_CHARSET, DEFAULT(mysql_real_data_home),
45104510
NO_MUTEX_GUARD, NOT_IN_BINLOG);
45114511

45124512
static Sys_var_charptr Sys_wsrep_cluster_name(

sql/wsrep_mysqld.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,6 @@ int wsrep_init()
559559
wsrep->provider_vendor, sizeof(provider_vendor) - 1);
560560
}
561561

562-
if (!wsrep_data_home_dir || strlen(wsrep_data_home_dir) == 0)
563-
wsrep_data_home_dir = mysql_real_data_home;
564-
565562
char node_addr[512]= { 0, };
566563
size_t const node_addr_max= sizeof(node_addr) - 1;
567564
if (!wsrep_node_address || !strcmp(wsrep_node_address, ""))

0 commit comments

Comments
 (0)