New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MDEV-14978] Client programs to use $MARIADB_HOST consistently #2556
base: 11.5
Are you sure you want to change the base?
Conversation
|
138e8bf
to
39dc8dd
Compare
This is an improved take on #1067. Please review and merge, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're able to update the man pages for these client utilities too that would be appreciated.
--let MYSQLDUMP = $MYSQL_BINDIR/client//mariadb-dump | ||
--let MYSQLIMPORT = $MYSQL_BINDIR/client//mariadb-import | ||
--let MYSQLSHOW = $MYSQL_BINDIR/client//mariadb-show | ||
--let MYSQLSLAP = $MYSQL_BINDIR/client//mariadb-slap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are all set in mysql-test/mariadb-test-run.pl, though usually as with underscore like $MYSQL_CHECK
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The environment variables for the client programs have a default options file argument in them. The options file was stopping me from testing the client programs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, they should probably be things like MARIABINLOG
, etc...
|
||
--echo **************** | ||
--echo # Setting MYSQL_HOST environment variable | ||
--let MYSQL_HOST=nonexistent-sever |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling "server"
--exec $MYSQLIMPORT $options env_variable --local $MYSQL_TMP_DIR/pet > /dev/null 2>&1 | ||
--exec $MYSQLSHOW $options env_variable > /dev/null 2>&1 | ||
--exec $MYSQLSLAP $options > /dev/null 2>&1 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there positive test examples using MYSQL_HOST MARIADB_HOST
maybe with --protocol tcp
?
Hi @grooverdan I updated my pull requested based off your feedback. I also updated the help function to include $MARIADB_HOST. In mysqlbinlog and mysqldump the memory is freed at the end during clean up so I was getting SIGSEV error when trying to use assignment. Assignments work for all the other client programs. For mysql client program would you like me to change it to $MARIADB_HOST in this pr also? Thanks for the review! |
# Clean up | ||
--echo Done | ||
DROP TABLE pet; | ||
--exec rm $MYSQL_TMP_DIR/tmp.sql |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--remove_file
for windows compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For mysql client program would you like me to change it to $MARIADB_HOST in this pr also?
Sure, but in this case $MARIADB_HOST
will be preferred over $MYSQL_HOST
so:
if (!(tmp= getenv("MARIADB_HOST"))
tmp= getenv("MYSQL_HOST")
...
client/mysqlcheck.c
Outdated
@@ -437,6 +437,9 @@ static int get_options(int *argc, char ***argv) | |||
int ho_error; | |||
DBUG_ENTER("get_options"); | |||
|
|||
if (current_host == NULL) | |||
current_host = getenv("MARIADB_HOST"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style fix (applies to all other code too),
current_host= getenv...
No space between var and =
.
EOF | ||
|
||
# Options for client program | ||
--let $options = --user=root --port=16000 --socket=$MYSQL_TMP_DIR/mysqld.1.sock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
port
and socket
aren't fixed.
$MASTER_MYPORT
and $MASTER_MYSOCK
(from mysql-test/include/default_my.cnf - no include required - its a default).
Or, if you create a client-env-variable.cnf
like:
!include include/default_my.cnf
[ENV]
MARIADB_HOST=localhost
This is a true environment variable.
Then $options
to be --port=$MASTER_MYPORT
(opmit socket so it doesn't get used) and use a positive test (no more --error
) to ensure the connection is there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no more --error
I am not sure if you want to remove the negative test case with --error
. I added the positive test case but kept the negative test case in the new revision.
I pushed a new revision based off feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, one more final cleanup pass and I think we are there.
client/mysqladmin.cc
Outdated
@@ -374,6 +373,9 @@ int main(int argc,char *argv[]) | |||
MYSQL mysql; | |||
char **commands, **save_argv, **temp_argv; | |||
|
|||
if (host==NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor style thing, spaces around ==
.
client/mysql.cc
Outdated
@@ -1704,8 +1704,8 @@ static struct my_option my_long_options[] = | |||
&opt_local_infile, &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, | |||
{"no-beep", 'b', "Turn off beep on error.", &opt_nobeep, | |||
&opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, | |||
{"host", 'h', "Connect to host.", ¤t_host, | |||
¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | |||
{"host", 'h', "Connect to host. If host is not specified, connect to localhost by default or $MARIADB_HOST", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect it would read better if this said something along the lines of "Defaults in the following order: environment variables MARIADB_HOST, MYSQL_HOST, and then localhost."
client/mysql.cc
Outdated
@@ -1704,8 +1704,8 @@ static struct my_option my_long_options[] = | |||
&opt_local_infile, &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, | |||
{"no-beep", 'b', "Turn off beep on error.", &opt_nobeep, | |||
&opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, | |||
{"host", 'h', "Connect to host.", ¤t_host, | |||
¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | |||
{"host", 'h', "Connect to host. If host is not specified, connect to localhost by default or $MARIADB_HOST", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, as a style thing, line is longer than 80 chars.
--let MYSQLDUMP = $MYSQL_BINDIR/client//mariadb-dump | ||
--let MYSQLIMPORT = $MYSQL_BINDIR/client//mariadb-import | ||
--let MYSQLSHOW = $MYSQL_BINDIR/client//mariadb-show | ||
--let MYSQLSLAP = $MYSQL_BINDIR/client//mariadb-slap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, they should probably be things like MARIABINLOG
, etc...
7ff6a6d
to
e9cc3dd
Compare
Only `mysql` client program was using $MYSQL_HOST as the default host. Add the same feature in most other client programs but using $MARIADB_HOST instead. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.
@LinuxJedi thanks for the feedback, I pushed a new revision based off your comments. Please review again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is the bases covered now, many thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. Ready for 11.6 testing.
optional improvement of manual pages welcome.
Description
Note: mysql_upgrade already uses environment variable as default. This feature was not added in for mysql_plugin and mysqltest
Only
mysql
client program was using $MYSQL_HOST as the default host.Add the same feature in most other client programs but using $MARIADB_HOST instead.
How can this PR be tested?
Set up environment variable
export MARIADB_HOST=your_test_server
Run each client program with the following commands:
client/mysqlslap -h another_test_server -P 3306 -u admin -p
client/mysqlslap -P 3306 -u admin -p
Verify that $MARIADB_HOST is used when
-h
is not specified. Also verify $MARIADB_HOST does not override command line argument.Basing the PR against the correct MariaDB version
Copyright
All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.